{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 加载数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:23:34.873789Z",
     "start_time": "2024-04-01T06:23:34.048699Z"
    }
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append(\"/home/loong/jupyter\")\n",
    "import common_utils\n",
    "from common_utils import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:23:56.073094Z",
     "start_time": "2024-04-01T06:23:35.437088Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load 574 file,data shape (313022, 8)\n",
      "(313022, 8)\n",
      "已经完成urule日志的加载: 2024-03-26 10:13:31\n"
     ]
    }
   ],
   "source": [
    "urule_log_dir = '/home/loong/jupyter/YuChuang/urule_log/data_mt'\n",
    "urule_log_paths = data_of_dir(urule_log_dir,\"type1\",'2023-11-22')\n",
    "urule_log_df = batch_load_data(urule_log_paths)\n",
    "print(urule_log_df.shape)\n",
    "print(\"已经完成urule日志的加载:\",urule_log_df['create_time'].max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:24:27.553726Z",
     "start_time": "2024-04-01T06:23:56.074292Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(219436, 13)\n",
      "当前可观测最晚订单的申请时间: 2024-03-26 00:32:10\n",
      "当前可观测最晚订单的还款时间: 2024-03-31\n"
     ]
    }
   ],
   "source": [
    "mysql_rule = mysql_engine('47.253.56.86',4001,'longxiaolei','WWsCQ9TXG+BJBHlK','rule')\n",
    "loan_sql = \"\"\"\n",
    "select\n",
    "      l.merchant_id,\n",
    "      l.tx_id,\n",
    "      l.acq_channel,\n",
    "       l.phone_number,\n",
    "       l.app_order_id,\n",
    "       l.device_type,\n",
    "       l.new_old_user_status,\n",
    "       l.repayment_date,\n",
    "       l.apply_time,\n",
    "       l.def_pd1,\n",
    "       l.agr_pd1,\n",
    "       l.def_cpd,\n",
    "       l.agr_cpd\n",
    "from rule.loan_v l where  merchant_id in ('AC', 'AM','AL','AG') and  l.agr_pd1=1\n",
    " and l.tx_id is not null\n",
    " and l.apply_time >= '2023-11-12'  -- and weekofyear(repayment_date)>=48 \n",
    "\"\"\"\n",
    "loan_df = pd.read_sql(loan_sql,mysql_rule)\n",
    "print(loan_df.shape)\n",
    "print(\"当前可观测最晚订单的申请时间:\",loan_df['apply_time'].max())\n",
    "print(\"当前可观测最晚订单的还款时间:\",loan_df['repayment_date'].max())\n",
    "\n",
    "loan_df['repayment_week'] = pd.to_datetime(loan_df['repayment_date']).map(format_date2week)\n",
    "\n",
    "urule_log_df['tx_id'] = urule_log_df['tx_id'].astype(str)\n",
    "loan_df['tx_id'] = loan_df['tx_id'].astype(str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:24:27.888804Z",
     "start_time": "2024-04-01T06:24:27.554815Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "表连接后: (207778, 15)\n"
     ]
    },
    {
     "data": {
      "text/plain": "0"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = urule_log_df[['merchant_id','tx_id','req_data']].merge(loan_df,on=['merchant_id','tx_id']) \n",
    "print(\"表连接后:\",df.shape)\n",
    "\n",
    "del urule_log_df\n",
    "del loan_df\n",
    "gc.collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:25:07.236001Z",
     "start_time": "2024-04-01T06:24:27.890306Z"
    }
   },
   "outputs": [],
   "source": [
    "columns = ['modelScoreParams_scoreV1','modelScoreParams_scoreV2','modelScoreParams_scoreV3','modelScoreParams_scoreV4','modelScoreParams_scoreV5','modelScoreParams_scoreV6',\n",
    "           'modelScoreParams_scoreV7','modelScoreParams_scoreV8','modelScoreParams_scoreV9','modelScoreParams_scoreV10','modelScoreParams_scoreV11','modelScoreParams_scoreV12',\n",
    "           'modelScoreParams_scoreV13']\n",
    "df[columns] = df.apply(lambda x : query_json(x['req_data'],columns),axis=1,result_type='expand')\n",
    "df[columns] = df[columns].astype(float)\n",
    "\n",
    "df = df.rename(columns={\n",
    "    'modelScoreParams_scoreV1':'scorev1',\n",
    "    'modelScoreParams_scoreV2':'scorev2',\n",
    "    'modelScoreParams_scoreV3':'scorev3',\n",
    "    'modelScoreParams_scoreV4':'scorev4',\n",
    "    'modelScoreParams_scoreV5':'scorev5',\n",
    "    'modelScoreParams_scoreV6':'scorev6',\n",
    "    'modelScoreParams_scoreV7':'scorev7',\n",
    "    'modelScoreParams_scoreV8':'scorev8',\n",
    "    'modelScoreParams_scoreV9':'scorev9',\n",
    "    'modelScoreParams_scoreV10':'scorev10',\n",
    "    'modelScoreParams_scoreV11':'scorev11',\n",
    "    'modelScoreParams_scoreV12':'scorev12',\n",
    "    'modelScoreParams_scoreV13':'scorev13',\n",
    "\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:25:09.025834Z",
     "start_time": "2024-04-01T06:25:07.237106Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "已经完成时间时间的转换 2024-03-25 23:08:56 2024.03.25~03.31\n"
     ]
    }
   ],
   "source": [
    "df['def_pd1'] = df.apply(def_pd1_aclc,axis=1)\n",
    "df['def_cpd'] = df.apply(def_cpd_aclc,axis=1)\n",
    "\n",
    "df.repayment_date = pd.to_datetime(df.repayment_date)\n",
    "print(\"已经完成时间时间的转换\",df['apply_time'].max(),df['repayment_week'].max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T06:25:09.029074Z",
     "start_time": "2024-04-01T06:25:09.027046Z"
    }
   },
   "outputs": [],
   "source": [
    "set_pd_show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# scorev1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T03:56:58.163635Z",
     "start_time": "2024-04-01T03:56:58.093092Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev1_bin  def_pd1   (-inf, 480.0]       203       239    442   \n1  scorev1_bin  def_pd1  (480.0, 520.0]      1867      1774   3641   \n2  scorev1_bin  def_pd1  (520.0, 540.0]      2057      1817   3874   \n3  scorev1_bin  def_pd1  (540.0, 580.0]      3532      2638   6170   \n4  scorev1_bin  def_pd1    (580.0, inf]      1201       608   1809   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.027736       0.540724 -0.374553  1.217775  0.075465  0.037599  \n1    0.228476       0.487229 -0.172988  1.097298  0.075465  0.037599  \n2    0.243097       0.469024 -0.100365  1.056299  0.075465  0.037599  \n3    0.387174       0.427553  0.066832  0.962900  0.075465  0.037599  \n4    0.113517       0.336097  0.451676  0.756931  0.075465  0.037599  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 480.0]</td>\n      <td>203</td>\n      <td>239</td>\n      <td>442</td>\n      <td>0.027736</td>\n      <td>0.540724</td>\n      <td>-0.374553</td>\n      <td>1.217775</td>\n      <td>0.075465</td>\n      <td>0.037599</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(480.0, 520.0]</td>\n      <td>1867</td>\n      <td>1774</td>\n      <td>3641</td>\n      <td>0.228476</td>\n      <td>0.487229</td>\n      <td>-0.172988</td>\n      <td>1.097298</td>\n      <td>0.075465</td>\n      <td>0.037599</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 540.0]</td>\n      <td>2057</td>\n      <td>1817</td>\n      <td>3874</td>\n      <td>0.243097</td>\n      <td>0.469024</td>\n      <td>-0.100365</td>\n      <td>1.056299</td>\n      <td>0.075465</td>\n      <td>0.037599</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(540.0, 580.0]</td>\n      <td>3532</td>\n      <td>2638</td>\n      <td>6170</td>\n      <td>0.387174</td>\n      <td>0.427553</td>\n      <td>0.066832</td>\n      <td>0.962900</td>\n      <td>0.075465</td>\n      <td>0.037599</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(580.0, inf]</td>\n      <td>1201</td>\n      <td>608</td>\n      <td>1809</td>\n      <td>0.113517</td>\n      <td>0.336097</td>\n      <td>0.451676</td>\n      <td>0.756931</td>\n      <td>0.075465</td>\n      <td>0.037599</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 0 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev1_bin'] = pd.cut(df['scorev1'],[-np.inf,480,520,540,580,np.inf])\n",
    "univerate(df[condition],'scorev1_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T03:58:39.266021Z",
     "start_time": "2024-04-01T03:58:39.220265Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev1_bin  def_pd1   (-inf, 480.0]       226       246    472   \n1  scorev1_bin  def_pd1  (480.0, 520.0]      1243      1348   2591   \n2  scorev1_bin  def_pd1  (520.0, 540.0]      1313      1232   2545   \n3  scorev1_bin  def_pd1  (540.0, 580.0]      4551      3140   7691   \n4  scorev1_bin  def_pd1    (580.0, inf]      2361      1252   3613   \n\n   total_rate  positive_rate       woe      LIFT       KS        IV  \n0    0.027909       0.521186 -0.366646  1.221156  0.10454  0.060206  \n1    0.153205       0.520262 -0.373595  1.218991  0.10454  0.060206  \n2    0.150485       0.484086 -0.229739  1.134230  0.10454  0.060206  \n3    0.454766       0.408269  0.076027  0.956588  0.10454  0.060206  \n4    0.213635       0.346526  0.337763  0.811922  0.10454  0.060206  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 480.0]</td>\n      <td>226</td>\n      <td>246</td>\n      <td>472</td>\n      <td>0.027909</td>\n      <td>0.521186</td>\n      <td>-0.366646</td>\n      <td>1.221156</td>\n      <td>0.10454</td>\n      <td>0.060206</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(480.0, 520.0]</td>\n      <td>1243</td>\n      <td>1348</td>\n      <td>2591</td>\n      <td>0.153205</td>\n      <td>0.520262</td>\n      <td>-0.373595</td>\n      <td>1.218991</td>\n      <td>0.10454</td>\n      <td>0.060206</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 540.0]</td>\n      <td>1313</td>\n      <td>1232</td>\n      <td>2545</td>\n      <td>0.150485</td>\n      <td>0.484086</td>\n      <td>-0.229739</td>\n      <td>1.134230</td>\n      <td>0.10454</td>\n      <td>0.060206</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(540.0, 580.0]</td>\n      <td>4551</td>\n      <td>3140</td>\n      <td>7691</td>\n      <td>0.454766</td>\n      <td>0.408269</td>\n      <td>0.076027</td>\n      <td>0.956588</td>\n      <td>0.10454</td>\n      <td>0.060206</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(580.0, inf]</td>\n      <td>2361</td>\n      <td>1252</td>\n      <td>3613</td>\n      <td>0.213635</td>\n      <td>0.346526</td>\n      <td>0.337763</td>\n      <td>0.811922</td>\n      <td>0.10454</td>\n      <td>0.060206</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 1 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev1_bin'] = pd.cut(df['scorev1'],[-np.inf,480,520,540,580,np.inf])\n",
    "univerate(df[condition],'scorev1_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T03:59:02.662322Z",
     "start_time": "2024-04-01T03:59:02.608026Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev1_bin  def_pd1   (-inf, 480.0]       175       249    424   \n1  scorev1_bin  def_pd1  (480.0, 520.0]      1199      1290   2489   \n2  scorev1_bin  def_pd1  (520.0, 540.0]      1197      1163   2360   \n3  scorev1_bin  def_pd1  (540.0, 580.0]      3193      2381   5574   \n4  scorev1_bin  def_pd1    (580.0, inf]      1589       932   2521   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.031718       0.587264 -0.536230  1.305162  0.099557  0.052454  \n1    0.186191       0.518280 -0.272544  1.151849  0.099557  0.052454  \n2    0.176541       0.492797 -0.171071  1.095213  0.099557  0.052454  \n3    0.416966       0.427162  0.092365  0.949343  0.099557  0.052454  \n4    0.188585       0.369695  0.330859  0.821625  0.099557  0.052454  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 480.0]</td>\n      <td>175</td>\n      <td>249</td>\n      <td>424</td>\n      <td>0.031718</td>\n      <td>0.587264</td>\n      <td>-0.536230</td>\n      <td>1.305162</td>\n      <td>0.099557</td>\n      <td>0.052454</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(480.0, 520.0]</td>\n      <td>1199</td>\n      <td>1290</td>\n      <td>2489</td>\n      <td>0.186191</td>\n      <td>0.518280</td>\n      <td>-0.272544</td>\n      <td>1.151849</td>\n      <td>0.099557</td>\n      <td>0.052454</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 540.0]</td>\n      <td>1197</td>\n      <td>1163</td>\n      <td>2360</td>\n      <td>0.176541</td>\n      <td>0.492797</td>\n      <td>-0.171071</td>\n      <td>1.095213</td>\n      <td>0.099557</td>\n      <td>0.052454</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(540.0, 580.0]</td>\n      <td>3193</td>\n      <td>2381</td>\n      <td>5574</td>\n      <td>0.416966</td>\n      <td>0.427162</td>\n      <td>0.092365</td>\n      <td>0.949343</td>\n      <td>0.099557</td>\n      <td>0.052454</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev1_bin</td>\n      <td>def_pd1</td>\n      <td>(580.0, inf]</td>\n      <td>1589</td>\n      <td>932</td>\n      <td>2521</td>\n      <td>0.188585</td>\n      <td>0.369695</td>\n      <td>0.330859</td>\n      <td>0.821625</td>\n      <td>0.099557</td>\n      <td>0.052454</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 2 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev1_bin'] = pd.cut(df['scorev1'],[-np.inf,480,520,540,580,np.inf])\n",
    "univerate(df[condition],'scorev1_bin','def_pd1') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-04-01T04:06:07.928218Z",
     "start_time": "2024-04-01T04:06:07.891653Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev1_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2023.11.27~12.03   (-inf, 480.0]        7       11        7       11   \n1   2023.11.27~12.03  (480.0, 520.0]       45       75       42       75   \n2   2023.11.27~12.03  (520.0, 540.0]       32       66       29       66   \n3   2023.11.27~12.03  (540.0, 580.0]       64      160       62      160   \n4   2023.11.27~12.03    (580.0, inf]       11       23       11       23   \n5   2023.12.04~12.10   (-inf, 480.0]       10       21       10       21   \n6   2023.12.04~12.10  (480.0, 520.0]       77      135       77      135   \n7   2023.12.04~12.10  (520.0, 540.0]       70      141       64      141   \n8   2023.12.04~12.10  (540.0, 580.0]       97      233       91      233   \n9   2023.12.04~12.10    (580.0, inf]       33       88       32       88   \n10  2023.12.11~12.17   (-inf, 480.0]       19       36       16       36   \n11  2023.12.11~12.17  (480.0, 520.0]       58      133       56      133   \n12  2023.12.11~12.17  (520.0, 540.0]       37       99       32       99   \n13  2023.12.11~12.17  (540.0, 580.0]       77      207       74      207   \n14  2023.12.11~12.17    (580.0, inf]       23       61       23       61   \n15  2023.12.18~12.24   (-inf, 480.0]       21       53       21       53   \n16  2023.12.18~12.24  (480.0, 520.0]      103      245      101      245   \n17  2023.12.18~12.24  (520.0, 540.0]       83      202       77      202   \n18  2023.12.18~12.24  (540.0, 580.0]      164      378      155      378   \n19  2023.12.18~12.24    (580.0, inf]       33       93       31       93   \n20  2023.12.25~12.31   (-inf, 480.0]       42       57       42       57   \n21  2023.12.25~12.31  (480.0, 520.0]       74      203       68      203   \n22  2023.12.25~12.31  (520.0, 540.0]       73      163       67      163   \n23  2023.12.25~12.31  (540.0, 580.0]      107      262      105      262   \n24  2023.12.25~12.31    (580.0, inf]       40       94       39       94   \n25  2024.01.01~01.07   (-inf, 480.0]       72      119       68      119   \n26  2024.01.01~01.07  (480.0, 520.0]      290      502      275      502   \n27  2024.01.01~01.07  (520.0, 540.0]      200      401      192      401   \n28  2024.01.01~01.07  (540.0, 580.0]      299      697      279      697   \n29  2024.01.01~01.07    (580.0, inf]       82      236       74      236   \n30  2024.01.08~01.14   (-inf, 480.0]       38       60       36       60   \n31  2024.01.08~01.14  (480.0, 520.0]      167      337      161      337   \n32  2024.01.08~01.14  (520.0, 540.0]      179      344      174      344   \n33  2024.01.08~01.14  (540.0, 580.0]      300      643      272      643   \n34  2024.01.08~01.14    (580.0, inf]       92      278       83      278   \n35  2024.01.15~01.21   (-inf, 480.0]       27       36       25       36   \n36  2024.01.15~01.21  (480.0, 520.0]      147      292      138      292   \n37  2024.01.15~01.21  (520.0, 540.0]      145      269      138      269   \n38  2024.01.15~01.21  (540.0, 580.0]      242      552      232      552   \n39  2024.01.15~01.21    (580.0, inf]       96      223       90      223   \n40  2024.01.22~01.28   (-inf, 480.0]       10       13       10       13   \n41  2024.01.22~01.28  (480.0, 520.0]      241      402      228      402   \n42  2024.01.22~01.28  (520.0, 540.0]      232      423      225      423   \n43  2024.01.22~01.28  (540.0, 580.0]      323      658      298      658   \n44  2024.01.22~01.28    (580.0, inf]      102      226       99      226   \n45  2024.01.29~02.04   (-inf, 480.0]        0        5        0        5   \n46  2024.01.29~02.04  (480.0, 520.0]       70      120       67      120   \n47  2024.01.29~02.04  (520.0, 540.0]       86      179       84      179   \n48  2024.01.29~02.04  (540.0, 580.0]      165      361      149      361   \n49  2024.01.29~02.04    (580.0, inf]       70      171       66      171   \n50  2024.02.05~02.11   (-inf, 480.0]        0        6        0        6   \n51  2024.02.05~02.11  (480.0, 520.0]        4       10        4       10   \n52  2024.02.05~02.11  (520.0, 540.0]        5       13        5       13   \n53  2024.02.05~02.11  (540.0, 580.0]       74      218       66      218   \n54  2024.02.05~02.11    (580.0, inf]       35      142       28      142   \n55  2024.02.12~02.18   (-inf, 480.0]        2        3        1        3   \n56  2024.02.12~02.18  (480.0, 520.0]        4        6        2        6   \n57  2024.02.12~02.18  (520.0, 540.0]        1        4        1        4   \n58  2024.02.12~02.18  (540.0, 580.0]       48      153       41      153   \n59  2024.02.12~02.18    (580.0, inf]       42      104       34      104   \n60  2024.02.19~02.25   (-inf, 480.0]        0        1        0        1   \n61  2024.02.19~02.25  (480.0, 520.0]        2        4        2        4   \n62  2024.02.19~02.25  (520.0, 540.0]        0        3        0        3   \n63  2024.02.19~02.25  (540.0, 580.0]       54      176       53      176   \n64  2024.02.19~02.25    (580.0, inf]       37      134       26      134   \n65  2024.02.26~03.03   (-inf, 480.0]        0        2        0        2   \n66  2024.02.26~03.03  (480.0, 520.0]        8       22        6       22   \n67  2024.02.26~03.03  (520.0, 540.0]       11       34       11       34   \n68  2024.02.26~03.03  (540.0, 580.0]       73      179       70      179   \n69  2024.02.26~03.03    (580.0, inf]       42      125       38      125   \n70  2024.03.04~03.10   (-inf, 480.0]        1        1        1        1   \n71  2024.03.04~03.10  (480.0, 520.0]        0        1        0        1   \n72  2024.03.04~03.10  (520.0, 540.0]        2        8        1        8   \n73  2024.03.04~03.10  (540.0, 580.0]       84      221       77      221   \n74  2024.03.04~03.10    (580.0, inf]       59      124       58      124   \n75  2024.03.11~03.17   (-inf, 480.0]        0        0        0        0   \n76  2024.03.11~03.17  (480.0, 520.0]        0        2        0        2   \n77  2024.03.11~03.17  (520.0, 540.0]        3        5        3        5   \n78  2024.03.11~03.17  (540.0, 580.0]       68      182       64      182   \n79  2024.03.11~03.17    (580.0, inf]       60      165       55      165   \n80  2024.03.18~03.24   (-inf, 480.0]        0        0        0        0   \n81  2024.03.18~03.24  (480.0, 520.0]        0        0        0        0   \n82  2024.03.18~03.24  (520.0, 540.0]        2        4        2        4   \n83  2024.03.18~03.24  (540.0, 580.0]       86      157       78      157   \n84  2024.03.18~03.24    (580.0, inf]       48      135       42      135   \n85  2024.03.25~03.31   (-inf, 480.0]        0        0        0        0   \n86  2024.03.25~03.31  (480.0, 520.0]        0        0        0        0   \n87  2024.03.25~03.31  (520.0, 540.0]        2        2        2        2   \n88  2024.03.25~03.31  (540.0, 580.0]       56      137       55      137   \n89  2024.03.25~03.31    (580.0, inf]       27       99       26       99   \n\n         pd1       cpd  \n0   0.636364  0.636364  \n1   0.600000  0.560000  \n2   0.484848  0.439394  \n3   0.400000  0.387500  \n4   0.478261  0.478261  \n5   0.476190  0.476190  \n6   0.570370  0.570370  \n7   0.496454  0.453901  \n8   0.416309  0.390558  \n9   0.375000  0.363636  \n10  0.527778  0.444444  \n11  0.436090  0.421053  \n12  0.373737  0.323232  \n13  0.371981  0.357488  \n14  0.377049  0.377049  \n15  0.396226  0.396226  \n16  0.420408  0.412245  \n17  0.410891  0.381188  \n18  0.433862  0.410053  \n19  0.354839  0.333333  \n20  0.736842  0.736842  \n21  0.364532  0.334975  \n22  0.447853  0.411043  \n23  0.408397  0.400763  \n24  0.425532  0.414894  \n25  0.605042  0.571429  \n26  0.577689  0.547809  \n27  0.498753  0.478803  \n28  0.428981  0.400287  \n29  0.347458  0.313559  \n30  0.633333  0.600000  \n31  0.495549  0.477745  \n32  0.520349  0.505814  \n33  0.466563  0.423017  \n34  0.330935  0.298561  \n35  0.750000  0.694444  \n36  0.503425  0.472603  \n37  0.539033  0.513011  \n38  0.438406  0.420290  \n39  0.430493  0.403587  \n40  0.769231  0.769231  \n41  0.599502  0.567164  \n42  0.548463  0.531915  \n43  0.490881  0.452888  \n44  0.451327  0.438053  \n45  0.000000  0.000000  \n46  0.583333  0.558333  \n47  0.480447  0.469274  \n48  0.457064  0.412742  \n49  0.409357  0.385965  \n50  0.000000  0.000000  \n51  0.400000  0.400000  \n52  0.384615  0.384615  \n53  0.339450  0.302752  \n54  0.246479  0.197183  \n55  0.666667  0.333333  \n56  0.666667  0.333333  \n57  0.250000  0.250000  \n58  0.313725  0.267974  \n59  0.403846  0.326923  \n60  0.000000  0.000000  \n61  0.500000  0.500000  \n62  0.000000  0.000000  \n63  0.306818  0.301136  \n64  0.276119  0.194030  \n65  0.000000  0.000000  \n66  0.363636  0.272727  \n67  0.323529  0.323529  \n68  0.407821  0.391061  \n69  0.336000  0.304000  \n70  1.000000  1.000000  \n71  0.000000  0.000000  \n72  0.250000  0.125000  \n73  0.380090  0.348416  \n74  0.475806  0.467742  \n75       NaN       NaN  \n76  0.000000  0.000000  \n77  0.600000  0.600000  \n78  0.373626  0.351648  \n79  0.363636  0.333333  \n80       NaN       NaN  \n81       NaN       NaN  \n82  0.500000  0.500000  \n83  0.547771  0.496815  \n84  0.355556  0.311111  \n85       NaN       NaN  \n86       NaN       NaN  \n87  1.000000  1.000000  \n88  0.408759  0.401460  \n89  0.272727  0.262626  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev1_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2023.11.27~12.03</td>\n      <td>(-inf, 480.0]</td>\n      <td>7</td>\n      <td>11</td>\n      <td>7</td>\n      <td>11</td>\n      <td>0.636364</td>\n      <td>0.636364</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2023.11.27~12.03</td>\n      <td>(480.0, 520.0]</td>\n      <td>45</td>\n      <td>75</td>\n      <td>42</td>\n      <td>75</td>\n      <td>0.600000</td>\n      <td>0.560000</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2023.11.27~12.03</td>\n      <td>(520.0, 540.0]</td>\n      <td>32</td>\n      <td>66</td>\n      <td>29</td>\n      <td>66</td>\n      <td>0.484848</td>\n      <td>0.439394</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2023.11.27~12.03</td>\n      <td>(540.0, 580.0]</td>\n      <td>64</td>\n      <td>160</td>\n      <td>62</td>\n      <td>160</td>\n      <td>0.400000</td>\n      <td>0.387500</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2023.11.27~12.03</td>\n      <td>(580.0, inf]</td>\n      <td>11</td>\n      <td>23</td>\n      <td>11</td>\n      <td>23</td>\n      <td>0.478261</td>\n      <td>0.478261</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2023.12.04~12.10</td>\n      <td>(-inf, 480.0]</td>\n      <td>10</td>\n      <td>21</td>\n      <td>10</td>\n      <td>21</td>\n      <td>0.476190</td>\n      <td>0.476190</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2023.12.04~12.10</td>\n      <td>(480.0, 520.0]</td>\n      <td>77</td>\n      <td>135</td>\n      <td>77</td>\n      <td>135</td>\n      <td>0.570370</td>\n      <td>0.570370</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2023.12.04~12.10</td>\n      <td>(520.0, 540.0]</td>\n      <td>70</td>\n      <td>141</td>\n      <td>64</td>\n      <td>141</td>\n      <td>0.496454</td>\n      <td>0.453901</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2023.12.04~12.10</td>\n      <td>(540.0, 580.0]</td>\n      <td>97</td>\n      <td>233</td>\n      <td>91</td>\n      <td>233</td>\n      <td>0.416309</td>\n      <td>0.390558</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2023.12.04~12.10</td>\n      <td>(580.0, inf]</td>\n      <td>33</td>\n      <td>88</td>\n      <td>32</td>\n      <td>88</td>\n      <td>0.375000</td>\n      <td>0.363636</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2023.12.11~12.17</td>\n      <td>(-inf, 480.0]</td>\n      <td>19</td>\n      <td>36</td>\n      <td>16</td>\n      <td>36</td>\n      <td>0.527778</td>\n      <td>0.444444</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2023.12.11~12.17</td>\n      <td>(480.0, 520.0]</td>\n      <td>58</td>\n      <td>133</td>\n      <td>56</td>\n      <td>133</td>\n      <td>0.436090</td>\n      <td>0.421053</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2023.12.11~12.17</td>\n      <td>(520.0, 540.0]</td>\n      <td>37</td>\n      <td>99</td>\n      <td>32</td>\n      <td>99</td>\n      <td>0.373737</td>\n      <td>0.323232</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2023.12.11~12.17</td>\n      <td>(540.0, 580.0]</td>\n      <td>77</td>\n      <td>207</td>\n      <td>74</td>\n      <td>207</td>\n      <td>0.371981</td>\n      <td>0.357488</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2023.12.11~12.17</td>\n      <td>(580.0, inf]</td>\n      <td>23</td>\n      <td>61</td>\n      <td>23</td>\n      <td>61</td>\n      <td>0.377049</td>\n      <td>0.377049</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2023.12.18~12.24</td>\n      <td>(-inf, 480.0]</td>\n      <td>21</td>\n      <td>53</td>\n      <td>21</td>\n      <td>53</td>\n      <td>0.396226</td>\n      <td>0.396226</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2023.12.18~12.24</td>\n      <td>(480.0, 520.0]</td>\n      <td>103</td>\n      <td>245</td>\n      <td>101</td>\n      <td>245</td>\n      <td>0.420408</td>\n      <td>0.412245</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2023.12.18~12.24</td>\n      <td>(520.0, 540.0]</td>\n      <td>83</td>\n      <td>202</td>\n      <td>77</td>\n      <td>202</td>\n      <td>0.410891</td>\n      <td>0.381188</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2023.12.18~12.24</td>\n      <td>(540.0, 580.0]</td>\n      <td>164</td>\n      <td>378</td>\n      <td>155</td>\n      <td>378</td>\n      <td>0.433862</td>\n      <td>0.410053</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2023.12.18~12.24</td>\n      <td>(580.0, inf]</td>\n      <td>33</td>\n      <td>93</td>\n      <td>31</td>\n      <td>93</td>\n      <td>0.354839</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2023.12.25~12.31</td>\n      <td>(-inf, 480.0]</td>\n      <td>42</td>\n      <td>57</td>\n      <td>42</td>\n      <td>57</td>\n      <td>0.736842</td>\n      <td>0.736842</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2023.12.25~12.31</td>\n      <td>(480.0, 520.0]</td>\n      <td>74</td>\n      <td>203</td>\n      <td>68</td>\n      <td>203</td>\n      <td>0.364532</td>\n      <td>0.334975</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2023.12.25~12.31</td>\n      <td>(520.0, 540.0]</td>\n      <td>73</td>\n      <td>163</td>\n      <td>67</td>\n      <td>163</td>\n      <td>0.447853</td>\n      <td>0.411043</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2023.12.25~12.31</td>\n      <td>(540.0, 580.0]</td>\n      <td>107</td>\n      <td>262</td>\n      <td>105</td>\n      <td>262</td>\n      <td>0.408397</td>\n      <td>0.400763</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2023.12.25~12.31</td>\n      <td>(580.0, inf]</td>\n      <td>40</td>\n      <td>94</td>\n      <td>39</td>\n      <td>94</td>\n      <td>0.425532</td>\n      <td>0.414894</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.01.01~01.07</td>\n      <td>(-inf, 480.0]</td>\n      <td>72</td>\n      <td>119</td>\n      <td>68</td>\n      <td>119</td>\n      <td>0.605042</td>\n      <td>0.571429</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.01.01~01.07</td>\n      <td>(480.0, 520.0]</td>\n      <td>290</td>\n      <td>502</td>\n      <td>275</td>\n      <td>502</td>\n      <td>0.577689</td>\n      <td>0.547809</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.01.01~01.07</td>\n      <td>(520.0, 540.0]</td>\n      <td>200</td>\n      <td>401</td>\n      <td>192</td>\n      <td>401</td>\n      <td>0.498753</td>\n      <td>0.478803</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.01.01~01.07</td>\n      <td>(540.0, 580.0]</td>\n      <td>299</td>\n      <td>697</td>\n      <td>279</td>\n      <td>697</td>\n      <td>0.428981</td>\n      <td>0.400287</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.01.01~01.07</td>\n      <td>(580.0, inf]</td>\n      <td>82</td>\n      <td>236</td>\n      <td>74</td>\n      <td>236</td>\n      <td>0.347458</td>\n      <td>0.313559</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.01.08~01.14</td>\n      <td>(-inf, 480.0]</td>\n      <td>38</td>\n      <td>60</td>\n      <td>36</td>\n      <td>60</td>\n      <td>0.633333</td>\n      <td>0.600000</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.01.08~01.14</td>\n      <td>(480.0, 520.0]</td>\n      <td>167</td>\n      <td>337</td>\n      <td>161</td>\n      <td>337</td>\n      <td>0.495549</td>\n      <td>0.477745</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.01.08~01.14</td>\n      <td>(520.0, 540.0]</td>\n      <td>179</td>\n      <td>344</td>\n      <td>174</td>\n      <td>344</td>\n      <td>0.520349</td>\n      <td>0.505814</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.01.08~01.14</td>\n      <td>(540.0, 580.0]</td>\n      <td>300</td>\n      <td>643</td>\n      <td>272</td>\n      <td>643</td>\n      <td>0.466563</td>\n      <td>0.423017</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.01.08~01.14</td>\n      <td>(580.0, inf]</td>\n      <td>92</td>\n      <td>278</td>\n      <td>83</td>\n      <td>278</td>\n      <td>0.330935</td>\n      <td>0.298561</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.01.15~01.21</td>\n      <td>(-inf, 480.0]</td>\n      <td>27</td>\n      <td>36</td>\n      <td>25</td>\n      <td>36</td>\n      <td>0.750000</td>\n      <td>0.694444</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.01.15~01.21</td>\n      <td>(480.0, 520.0]</td>\n      <td>147</td>\n      <td>292</td>\n      <td>138</td>\n      <td>292</td>\n      <td>0.503425</td>\n      <td>0.472603</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.01.15~01.21</td>\n      <td>(520.0, 540.0]</td>\n      <td>145</td>\n      <td>269</td>\n      <td>138</td>\n      <td>269</td>\n      <td>0.539033</td>\n      <td>0.513011</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.01.15~01.21</td>\n      <td>(540.0, 580.0]</td>\n      <td>242</td>\n      <td>552</td>\n      <td>232</td>\n      <td>552</td>\n      <td>0.438406</td>\n      <td>0.420290</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.01.15~01.21</td>\n      <td>(580.0, inf]</td>\n      <td>96</td>\n      <td>223</td>\n      <td>90</td>\n      <td>223</td>\n      <td>0.430493</td>\n      <td>0.403587</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.01.22~01.28</td>\n      <td>(-inf, 480.0]</td>\n      <td>10</td>\n      <td>13</td>\n      <td>10</td>\n      <td>13</td>\n      <td>0.769231</td>\n      <td>0.769231</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.01.22~01.28</td>\n      <td>(480.0, 520.0]</td>\n      <td>241</td>\n      <td>402</td>\n      <td>228</td>\n      <td>402</td>\n      <td>0.599502</td>\n      <td>0.567164</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.01.22~01.28</td>\n      <td>(520.0, 540.0]</td>\n      <td>232</td>\n      <td>423</td>\n      <td>225</td>\n      <td>423</td>\n      <td>0.548463</td>\n      <td>0.531915</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.01.22~01.28</td>\n      <td>(540.0, 580.0]</td>\n      <td>323</td>\n      <td>658</td>\n      <td>298</td>\n      <td>658</td>\n      <td>0.490881</td>\n      <td>0.452888</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.01.22~01.28</td>\n      <td>(580.0, inf]</td>\n      <td>102</td>\n      <td>226</td>\n      <td>99</td>\n      <td>226</td>\n      <td>0.451327</td>\n      <td>0.438053</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.01.29~02.04</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>5</td>\n      <td>0</td>\n      <td>5</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.01.29~02.04</td>\n      <td>(480.0, 520.0]</td>\n      <td>70</td>\n      <td>120</td>\n      <td>67</td>\n      <td>120</td>\n      <td>0.583333</td>\n      <td>0.558333</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.01.29~02.04</td>\n      <td>(520.0, 540.0]</td>\n      <td>86</td>\n      <td>179</td>\n      <td>84</td>\n      <td>179</td>\n      <td>0.480447</td>\n      <td>0.469274</td>\n    </tr>\n    <tr>\n      <th>48</th>\n      <td>2024.01.29~02.04</td>\n      <td>(540.0, 580.0]</td>\n      <td>165</td>\n      <td>361</td>\n      <td>149</td>\n      <td>361</td>\n      <td>0.457064</td>\n      <td>0.412742</td>\n    </tr>\n    <tr>\n      <th>49</th>\n      <td>2024.01.29~02.04</td>\n      <td>(580.0, inf]</td>\n      <td>70</td>\n      <td>171</td>\n      <td>66</td>\n      <td>171</td>\n      <td>0.409357</td>\n      <td>0.385965</td>\n    </tr>\n    <tr>\n      <th>50</th>\n      <td>2024.02.05~02.11</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>6</td>\n      <td>0</td>\n      <td>6</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>51</th>\n      <td>2024.02.05~02.11</td>\n      <td>(480.0, 520.0]</td>\n      <td>4</td>\n      <td>10</td>\n      <td>4</td>\n      <td>10</td>\n      <td>0.400000</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>52</th>\n      <td>2024.02.05~02.11</td>\n      <td>(520.0, 540.0]</td>\n      <td>5</td>\n      <td>13</td>\n      <td>5</td>\n      <td>13</td>\n      <td>0.384615</td>\n      <td>0.384615</td>\n    </tr>\n    <tr>\n      <th>53</th>\n      <td>2024.02.05~02.11</td>\n      <td>(540.0, 580.0]</td>\n      <td>74</td>\n      <td>218</td>\n      <td>66</td>\n      <td>218</td>\n      <td>0.339450</td>\n      <td>0.302752</td>\n    </tr>\n    <tr>\n      <th>54</th>\n      <td>2024.02.05~02.11</td>\n      <td>(580.0, inf]</td>\n      <td>35</td>\n      <td>142</td>\n      <td>28</td>\n      <td>142</td>\n      <td>0.246479</td>\n      <td>0.197183</td>\n    </tr>\n    <tr>\n      <th>55</th>\n      <td>2024.02.12~02.18</td>\n      <td>(-inf, 480.0]</td>\n      <td>2</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>0.666667</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>56</th>\n      <td>2024.02.12~02.18</td>\n      <td>(480.0, 520.0]</td>\n      <td>4</td>\n      <td>6</td>\n      <td>2</td>\n      <td>6</td>\n      <td>0.666667</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>57</th>\n      <td>2024.02.12~02.18</td>\n      <td>(520.0, 540.0]</td>\n      <td>1</td>\n      <td>4</td>\n      <td>1</td>\n      <td>4</td>\n      <td>0.250000</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>58</th>\n      <td>2024.02.12~02.18</td>\n      <td>(540.0, 580.0]</td>\n      <td>48</td>\n      <td>153</td>\n      <td>41</td>\n      <td>153</td>\n      <td>0.313725</td>\n      <td>0.267974</td>\n    </tr>\n    <tr>\n      <th>59</th>\n      <td>2024.02.12~02.18</td>\n      <td>(580.0, inf]</td>\n      <td>42</td>\n      <td>104</td>\n      <td>34</td>\n      <td>104</td>\n      <td>0.403846</td>\n      <td>0.326923</td>\n    </tr>\n    <tr>\n      <th>60</th>\n      <td>2024.02.19~02.25</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>61</th>\n      <td>2024.02.19~02.25</td>\n      <td>(480.0, 520.0]</td>\n      <td>2</td>\n      <td>4</td>\n      <td>2</td>\n      <td>4</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>62</th>\n      <td>2024.02.19~02.25</td>\n      <td>(520.0, 540.0]</td>\n      <td>0</td>\n      <td>3</td>\n      <td>0</td>\n      <td>3</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>63</th>\n      <td>2024.02.19~02.25</td>\n      <td>(540.0, 580.0]</td>\n      <td>54</td>\n      <td>176</td>\n      <td>53</td>\n      <td>176</td>\n      <td>0.306818</td>\n      <td>0.301136</td>\n    </tr>\n    <tr>\n      <th>64</th>\n      <td>2024.02.19~02.25</td>\n      <td>(580.0, inf]</td>\n      <td>37</td>\n      <td>134</td>\n      <td>26</td>\n      <td>134</td>\n      <td>0.276119</td>\n      <td>0.194030</td>\n    </tr>\n    <tr>\n      <th>65</th>\n      <td>2024.02.26~03.03</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>66</th>\n      <td>2024.02.26~03.03</td>\n      <td>(480.0, 520.0]</td>\n      <td>8</td>\n      <td>22</td>\n      <td>6</td>\n      <td>22</td>\n      <td>0.363636</td>\n      <td>0.272727</td>\n    </tr>\n    <tr>\n      <th>67</th>\n      <td>2024.02.26~03.03</td>\n      <td>(520.0, 540.0]</td>\n      <td>11</td>\n      <td>34</td>\n      <td>11</td>\n      <td>34</td>\n      <td>0.323529</td>\n      <td>0.323529</td>\n    </tr>\n    <tr>\n      <th>68</th>\n      <td>2024.02.26~03.03</td>\n      <td>(540.0, 580.0]</td>\n      <td>73</td>\n      <td>179</td>\n      <td>70</td>\n      <td>179</td>\n      <td>0.407821</td>\n      <td>0.391061</td>\n    </tr>\n    <tr>\n      <th>69</th>\n      <td>2024.02.26~03.03</td>\n      <td>(580.0, inf]</td>\n      <td>42</td>\n      <td>125</td>\n      <td>38</td>\n      <td>125</td>\n      <td>0.336000</td>\n      <td>0.304000</td>\n    </tr>\n    <tr>\n      <th>70</th>\n      <td>2024.03.04~03.10</td>\n      <td>(-inf, 480.0]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>71</th>\n      <td>2024.03.04~03.10</td>\n      <td>(480.0, 520.0]</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>72</th>\n      <td>2024.03.04~03.10</td>\n      <td>(520.0, 540.0]</td>\n      <td>2</td>\n      <td>8</td>\n      <td>1</td>\n      <td>8</td>\n      <td>0.250000</td>\n      <td>0.125000</td>\n    </tr>\n    <tr>\n      <th>73</th>\n      <td>2024.03.04~03.10</td>\n      <td>(540.0, 580.0]</td>\n      <td>84</td>\n      <td>221</td>\n      <td>77</td>\n      <td>221</td>\n      <td>0.380090</td>\n      <td>0.348416</td>\n    </tr>\n    <tr>\n      <th>74</th>\n      <td>2024.03.04~03.10</td>\n      <td>(580.0, inf]</td>\n      <td>59</td>\n      <td>124</td>\n      <td>58</td>\n      <td>124</td>\n      <td>0.475806</td>\n      <td>0.467742</td>\n    </tr>\n    <tr>\n      <th>75</th>\n      <td>2024.03.11~03.17</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>76</th>\n      <td>2024.03.11~03.17</td>\n      <td>(480.0, 520.0]</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>77</th>\n      <td>2024.03.11~03.17</td>\n      <td>(520.0, 540.0]</td>\n      <td>3</td>\n      <td>5</td>\n      <td>3</td>\n      <td>5</td>\n      <td>0.600000</td>\n      <td>0.600000</td>\n    </tr>\n    <tr>\n      <th>78</th>\n      <td>2024.03.11~03.17</td>\n      <td>(540.0, 580.0]</td>\n      <td>68</td>\n      <td>182</td>\n      <td>64</td>\n      <td>182</td>\n      <td>0.373626</td>\n      <td>0.351648</td>\n    </tr>\n    <tr>\n      <th>79</th>\n      <td>2024.03.11~03.17</td>\n      <td>(580.0, inf]</td>\n      <td>60</td>\n      <td>165</td>\n      <td>55</td>\n      <td>165</td>\n      <td>0.363636</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>80</th>\n      <td>2024.03.18~03.24</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>81</th>\n      <td>2024.03.18~03.24</td>\n      <td>(480.0, 520.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>82</th>\n      <td>2024.03.18~03.24</td>\n      <td>(520.0, 540.0]</td>\n      <td>2</td>\n      <td>4</td>\n      <td>2</td>\n      <td>4</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>83</th>\n      <td>2024.03.18~03.24</td>\n      <td>(540.0, 580.0]</td>\n      <td>86</td>\n      <td>157</td>\n      <td>78</td>\n      <td>157</td>\n      <td>0.547771</td>\n      <td>0.496815</td>\n    </tr>\n    <tr>\n      <th>84</th>\n      <td>2024.03.18~03.24</td>\n      <td>(580.0, inf]</td>\n      <td>48</td>\n      <td>135</td>\n      <td>42</td>\n      <td>135</td>\n      <td>0.355556</td>\n      <td>0.311111</td>\n    </tr>\n    <tr>\n      <th>85</th>\n      <td>2024.03.25~03.31</td>\n      <td>(-inf, 480.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>86</th>\n      <td>2024.03.25~03.31</td>\n      <td>(480.0, 520.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>87</th>\n      <td>2024.03.25~03.31</td>\n      <td>(520.0, 540.0]</td>\n      <td>2</td>\n      <td>2</td>\n      <td>2</td>\n      <td>2</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>88</th>\n      <td>2024.03.25~03.31</td>\n      <td>(540.0, 580.0]</td>\n      <td>56</td>\n      <td>137</td>\n      <td>55</td>\n      <td>137</td>\n      <td>0.408759</td>\n      <td>0.401460</td>\n    </tr>\n    <tr>\n      <th>89</th>\n      <td>2024.03.25~03.31</td>\n      <td>(580.0, inf]</td>\n      <td>27</td>\n      <td>99</td>\n      <td>26</td>\n      <td>99</td>\n      <td>0.272727</td>\n      <td>0.262626</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AM') & (df.device_type ==\"android\") & (df.new_old_user_status== 2 ) & (df.scorev1>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev1_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev2"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev2_bin  def_pd1   (-inf, 500.0]        10        21     31   \n1  scorev2_bin  def_pd1  (500.0, 520.0]       286       377    663   \n2  scorev2_bin  def_pd1  (520.0, 550.0]      1239      1113   2352   \n3  scorev2_bin  def_pd1  (550.0, 570.0]      1353       969   2322   \n4  scorev2_bin  def_pd1  (570.0, 605.0]      2396      1083   3479   \n5  scorev2_bin  def_pd1    (605.0, inf]      1456       590   2046   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.002846       0.677419 -0.891405  1.776819  0.168672  0.135888  \n1    0.060865       0.568627 -0.748145  1.491466  0.168672  0.135888  \n2    0.215918       0.473214 -0.375283  1.241205  0.168672  0.135888  \n3    0.213164       0.417313 -0.149721  1.094579  0.168672  0.135888  \n4    0.319379       0.311296  0.308818  0.816506  0.168672  0.135888  \n5    0.187827       0.288368  0.416701  0.756366  0.168672  0.135888  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev2_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 500.0]</td>\n      <td>10</td>\n      <td>21</td>\n      <td>31</td>\n      <td>0.002846</td>\n      <td>0.677419</td>\n      <td>-0.891405</td>\n      <td>1.776819</td>\n      <td>0.168672</td>\n      <td>0.135888</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev2_bin</td>\n      <td>def_pd1</td>\n      <td>(500.0, 520.0]</td>\n      <td>286</td>\n      <td>377</td>\n      <td>663</td>\n      <td>0.060865</td>\n      <td>0.568627</td>\n      <td>-0.748145</td>\n      <td>1.491466</td>\n      <td>0.168672</td>\n      <td>0.135888</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev2_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 550.0]</td>\n      <td>1239</td>\n      <td>1113</td>\n      <td>2352</td>\n      <td>0.215918</td>\n      <td>0.473214</td>\n      <td>-0.375283</td>\n      <td>1.241205</td>\n      <td>0.168672</td>\n      <td>0.135888</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev2_bin</td>\n      <td>def_pd1</td>\n      <td>(550.0, 570.0]</td>\n      <td>1353</td>\n      <td>969</td>\n      <td>2322</td>\n      <td>0.213164</td>\n      <td>0.417313</td>\n      <td>-0.149721</td>\n      <td>1.094579</td>\n      <td>0.168672</td>\n      <td>0.135888</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev2_bin</td>\n      <td>def_pd1</td>\n      <td>(570.0, 605.0]</td>\n      <td>2396</td>\n      <td>1083</td>\n      <td>3479</td>\n      <td>0.319379</td>\n      <td>0.311296</td>\n      <td>0.308818</td>\n      <td>0.816506</td>\n      <td>0.168672</td>\n      <td>0.135888</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>scorev2_bin</td>\n      <td>def_pd1</td>\n      <td>(605.0, inf]</td>\n      <td>1456</td>\n      <td>590</td>\n      <td>2046</td>\n      <td>0.187827</td>\n      <td>0.288368</td>\n      <td>0.416701</td>\n      <td>0.756366</td>\n      <td>0.168672</td>\n      <td>0.135888</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition  = (df.merchant_id=='AC') & (df.device_type ==\"android\") & (df.new_old_user_status== 0 ) & (df.scorev2>0) & (df.repayment_date>=pd.to_datetime('2023-11-27'))\n",
    "df['scorev2_bin'] = pd.cut(df['scorev2'],[-np.inf,500,520,550,570,605,np.inf])\n",
    "univerate(df[condition],'scorev2_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:07:30.519405Z",
     "start_time": "2024-04-01T04:07:30.480038Z"
    }
   },
   "execution_count": 23
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "       repayment_week     scorev2_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0    2023.12.04~12.10   (-inf, 500.0]        3        3        3        3   \n1    2023.12.04~12.10  (500.0, 520.0]        4        6        4        6   \n2    2023.12.04~12.10  (520.0, 550.0]       25       37       23       37   \n3    2023.12.04~12.10  (550.0, 570.0]       14       25       11       25   \n4    2023.12.04~12.10  (570.0, 605.0]       26       58       22       58   \n5    2023.12.04~12.10    (605.0, inf]        3       25        3       25   \n6    2023.12.11~12.17   (-inf, 500.0]        4        7        3        7   \n7    2023.12.11~12.17  (500.0, 520.0]       17       25       17       25   \n8    2023.12.11~12.17  (520.0, 550.0]       41       78       34       78   \n9    2023.12.11~12.17  (550.0, 570.0]       64      124       51      124   \n10   2023.12.11~12.17  (570.0, 605.0]       77      233       63      233   \n11   2023.12.11~12.17    (605.0, inf]       54      164       41      164   \n12   2023.12.18~12.24   (-inf, 500.0]        2        2        2        2   \n13   2023.12.18~12.24  (500.0, 520.0]        8       14        8       14   \n14   2023.12.18~12.24  (520.0, 550.0]       38       73       35       73   \n15   2023.12.18~12.24  (550.0, 570.0]       37       85       32       85   \n16   2023.12.18~12.24  (570.0, 605.0]       58      183       46      183   \n17   2023.12.18~12.24    (605.0, inf]       18      114       13      114   \n18   2023.12.25~12.31   (-inf, 500.0]        1        1        0        1   \n19   2023.12.25~12.31  (500.0, 520.0]        1        3        1        3   \n20   2023.12.25~12.31  (520.0, 550.0]        9       18        9       18   \n21   2023.12.25~12.31  (550.0, 570.0]       12       30        9       30   \n22   2023.12.25~12.31  (570.0, 605.0]       26       74       22       74   \n23   2023.12.25~12.31    (605.0, inf]       16       46        9       46   \n24   2024.01.01~01.07   (-inf, 500.0]        0        1        0        1   \n25   2024.01.01~01.07  (500.0, 520.0]       20       36       19       36   \n26   2024.01.01~01.07  (520.0, 550.0]       56       94       52       94   \n27   2024.01.01~01.07  (550.0, 570.0]       59      123       56      123   \n28   2024.01.01~01.07  (570.0, 605.0]       94      272       80      272   \n29   2024.01.01~01.07    (605.0, inf]       81      276       60      276   \n30   2024.01.08~01.14   (-inf, 500.0]        1        1        1        1   \n31   2024.01.08~01.14  (500.0, 520.0]       15       35       14       35   \n32   2024.01.08~01.14  (520.0, 550.0]       63      101       58      101   \n33   2024.01.08~01.14  (550.0, 570.0]      160      305      148      305   \n34   2024.01.08~01.14  (570.0, 605.0]      150      368      136      368   \n35   2024.01.08~01.14    (605.0, inf]      113      346       95      346   \n36   2024.01.15~01.21   (-inf, 500.0]        0        0        0        0   \n37   2024.01.15~01.21  (500.0, 520.0]       60       94       58       94   \n38   2024.01.15~01.21  (520.0, 550.0]       97      191       93      191   \n39   2024.01.15~01.21  (550.0, 570.0]       66      181       58      181   \n40   2024.01.15~01.21  (570.0, 605.0]       94      341       86      341   \n41   2024.01.15~01.21    (605.0, inf]       66      227       48      227   \n42   2024.01.22~01.28   (-inf, 500.0]        0        0        0        0   \n43   2024.01.22~01.28  (500.0, 520.0]       18       28       16       28   \n44   2024.01.22~01.28  (520.0, 550.0]       98      226       88      226   \n45   2024.01.22~01.28  (550.0, 570.0]       66      170       53      170   \n46   2024.01.22~01.28  (570.0, 605.0]       78      283       58      283   \n47   2024.01.22~01.28    (605.0, inf]       36      142       29      142   \n48   2024.01.29~02.04   (-inf, 500.0]        0        0        0        0   \n49   2024.01.29~02.04  (500.0, 520.0]       28       47       26       47   \n50   2024.01.29~02.04  (520.0, 550.0]      131      306      114      306   \n51   2024.01.29~02.04  (550.0, 570.0]       81      240       69      240   \n52   2024.01.29~02.04  (570.0, 605.0]       88      366       70      366   \n53   2024.01.29~02.04    (605.0, inf]       50      162       42      162   \n54   2024.02.05~02.11   (-inf, 500.0]        0        0        0        0   \n55   2024.02.05~02.11  (500.0, 520.0]       10       13       10       13   \n56   2024.02.05~02.11  (520.0, 550.0]       82      174       74      174   \n57   2024.02.05~02.11  (550.0, 570.0]       65      171       48      171   \n58   2024.02.05~02.11  (570.0, 605.0]       69      268       53      268   \n59   2024.02.05~02.11    (605.0, inf]       25      109       21      109   \n60   2024.02.12~02.18   (-inf, 500.0]        0        0        0        0   \n61   2024.02.12~02.18  (500.0, 520.0]        2        6        2        6   \n62   2024.02.12~02.18  (520.0, 550.0]       55      154       48      154   \n63   2024.02.12~02.18  (550.0, 570.0]       61      153       47      153   \n64   2024.02.12~02.18  (570.0, 605.0]       75      228       59      228   \n65   2024.02.12~02.18    (605.0, inf]       26       95       21       95   \n66   2024.02.19~02.25   (-inf, 500.0]        0        0        0        0   \n67   2024.02.19~02.25  (500.0, 520.0]        6        8        6        8   \n68   2024.02.19~02.25  (520.0, 550.0]       62      155       52      155   \n69   2024.02.19~02.25  (550.0, 570.0]       65      171       49      171   \n70   2024.02.19~02.25  (570.0, 605.0]       80      214       65      214   \n71   2024.02.19~02.25    (605.0, inf]       27       94       20       94   \n72   2024.02.26~03.03   (-inf, 500.0]        0        0        0        0   \n73   2024.02.26~03.03  (500.0, 520.0]        1        3        1        3   \n74   2024.02.26~03.03  (520.0, 550.0]       53      122       48      122   \n75   2024.02.26~03.03  (550.0, 570.0]       53      147       42      147   \n76   2024.02.26~03.03  (570.0, 605.0]       62      209       52      209   \n77   2024.02.26~03.03    (605.0, inf]       29      100       21      100   \n78   2024.03.04~03.10   (-inf, 500.0]        1        2        1        2   \n79   2024.03.04~03.10  (500.0, 520.0]       18       49       17       49   \n80   2024.03.04~03.10  (520.0, 550.0]       46      127       44      127   \n81   2024.03.04~03.10  (550.0, 570.0]       40      127       37      127   \n82   2024.03.04~03.10  (570.0, 605.0]       30      126       26      126   \n83   2024.03.04~03.10    (605.0, inf]       18       65       15       65   \n84   2024.03.11~03.17   (-inf, 500.0]        6       10        6       10   \n85   2024.03.11~03.17  (500.0, 520.0]       98      168       94      168   \n86   2024.03.11~03.17  (520.0, 550.0]      132      250      122      250   \n87   2024.03.11~03.17  (550.0, 570.0]       58      131       46      131   \n88   2024.03.11~03.17  (570.0, 605.0]       37      126       30      126   \n89   2024.03.11~03.17    (605.0, inf]       12       43       11       43   \n90   2024.03.18~03.24   (-inf, 500.0]        3        4        3        4   \n91   2024.03.18~03.24  (500.0, 520.0]       61      115       55      115   \n92   2024.03.18~03.24  (520.0, 550.0]       99      197       91      197   \n93   2024.03.18~03.24  (550.0, 570.0]       46       95       39       95   \n94   2024.03.18~03.24  (570.0, 605.0]       24       75       21       75   \n95   2024.03.18~03.24    (605.0, inf]       14       28       10       28   \n96   2024.03.25~03.31   (-inf, 500.0]        0        0        0        0   \n97   2024.03.25~03.31  (500.0, 520.0]       10       13        7       13   \n98   2024.03.25~03.31  (520.0, 550.0]       26       49       24       49   \n99   2024.03.25~03.31  (550.0, 570.0]       22       44       20       44   \n100  2024.03.25~03.31  (570.0, 605.0]       15       55       14       55   \n101  2024.03.25~03.31    (605.0, inf]        2       10        2       10   \n\n          pd1       cpd  \n0    1.000000  1.000000  \n1    0.666667  0.666667  \n2    0.675676  0.621622  \n3    0.560000  0.440000  \n4    0.448276  0.379310  \n5    0.120000  0.120000  \n6    0.571429  0.428571  \n7    0.680000  0.680000  \n8    0.525641  0.435897  \n9    0.516129  0.411290  \n10   0.330472  0.270386  \n11   0.329268  0.250000  \n12   1.000000  1.000000  \n13   0.571429  0.571429  \n14   0.520548  0.479452  \n15   0.435294  0.376471  \n16   0.316940  0.251366  \n17   0.157895  0.114035  \n18   1.000000  0.000000  \n19   0.333333  0.333333  \n20   0.500000  0.500000  \n21   0.400000  0.300000  \n22   0.351351  0.297297  \n23   0.347826  0.195652  \n24   0.000000  0.000000  \n25   0.555556  0.527778  \n26   0.595745  0.553191  \n27   0.479675  0.455285  \n28   0.345588  0.294118  \n29   0.293478  0.217391  \n30   1.000000  1.000000  \n31   0.428571  0.400000  \n32   0.623762  0.574257  \n33   0.524590  0.485246  \n34   0.407609  0.369565  \n35   0.326590  0.274566  \n36        NaN       NaN  \n37   0.638298  0.617021  \n38   0.507853  0.486911  \n39   0.364641  0.320442  \n40   0.275660  0.252199  \n41   0.290749  0.211454  \n42        NaN       NaN  \n43   0.642857  0.571429  \n44   0.433628  0.389381  \n45   0.388235  0.311765  \n46   0.275618  0.204947  \n47   0.253521  0.204225  \n48        NaN       NaN  \n49   0.595745  0.553191  \n50   0.428105  0.372549  \n51   0.337500  0.287500  \n52   0.240437  0.191257  \n53   0.308642  0.259259  \n54        NaN       NaN  \n55   0.769231  0.769231  \n56   0.471264  0.425287  \n57   0.380117  0.280702  \n58   0.257463  0.197761  \n59   0.229358  0.192661  \n60        NaN       NaN  \n61   0.333333  0.333333  \n62   0.357143  0.311688  \n63   0.398693  0.307190  \n64   0.328947  0.258772  \n65   0.273684  0.221053  \n66        NaN       NaN  \n67   0.750000  0.750000  \n68   0.400000  0.335484  \n69   0.380117  0.286550  \n70   0.373832  0.303738  \n71   0.287234  0.212766  \n72        NaN       NaN  \n73   0.333333  0.333333  \n74   0.434426  0.393443  \n75   0.360544  0.285714  \n76   0.296651  0.248804  \n77   0.290000  0.210000  \n78   0.500000  0.500000  \n79   0.367347  0.346939  \n80   0.362205  0.346457  \n81   0.314961  0.291339  \n82   0.238095  0.206349  \n83   0.276923  0.230769  \n84   0.600000  0.600000  \n85   0.583333  0.559524  \n86   0.528000  0.488000  \n87   0.442748  0.351145  \n88   0.293651  0.238095  \n89   0.279070  0.255814  \n90   0.750000  0.750000  \n91   0.530435  0.478261  \n92   0.502538  0.461929  \n93   0.484211  0.410526  \n94   0.320000  0.280000  \n95   0.500000  0.357143  \n96        NaN       NaN  \n97   0.769231  0.538462  \n98   0.530612  0.489796  \n99   0.500000  0.454545  \n100  0.272727  0.254545  \n101  0.200000  0.200000  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev2_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2023.12.04~12.10</td>\n      <td>(-inf, 500.0]</td>\n      <td>3</td>\n      <td>3</td>\n      <td>3</td>\n      <td>3</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2023.12.04~12.10</td>\n      <td>(500.0, 520.0]</td>\n      <td>4</td>\n      <td>6</td>\n      <td>4</td>\n      <td>6</td>\n      <td>0.666667</td>\n      <td>0.666667</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2023.12.04~12.10</td>\n      <td>(520.0, 550.0]</td>\n      <td>25</td>\n      <td>37</td>\n      <td>23</td>\n      <td>37</td>\n      <td>0.675676</td>\n      <td>0.621622</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2023.12.04~12.10</td>\n      <td>(550.0, 570.0]</td>\n      <td>14</td>\n      <td>25</td>\n      <td>11</td>\n      <td>25</td>\n      <td>0.560000</td>\n      <td>0.440000</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2023.12.04~12.10</td>\n      <td>(570.0, 605.0]</td>\n      <td>26</td>\n      <td>58</td>\n      <td>22</td>\n      <td>58</td>\n      <td>0.448276</td>\n      <td>0.379310</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2023.12.04~12.10</td>\n      <td>(605.0, inf]</td>\n      <td>3</td>\n      <td>25</td>\n      <td>3</td>\n      <td>25</td>\n      <td>0.120000</td>\n      <td>0.120000</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2023.12.11~12.17</td>\n      <td>(-inf, 500.0]</td>\n      <td>4</td>\n      <td>7</td>\n      <td>3</td>\n      <td>7</td>\n      <td>0.571429</td>\n      <td>0.428571</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2023.12.11~12.17</td>\n      <td>(500.0, 520.0]</td>\n      <td>17</td>\n      <td>25</td>\n      <td>17</td>\n      <td>25</td>\n      <td>0.680000</td>\n      <td>0.680000</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2023.12.11~12.17</td>\n      <td>(520.0, 550.0]</td>\n      <td>41</td>\n      <td>78</td>\n      <td>34</td>\n      <td>78</td>\n      <td>0.525641</td>\n      <td>0.435897</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2023.12.11~12.17</td>\n      <td>(550.0, 570.0]</td>\n      <td>64</td>\n      <td>124</td>\n      <td>51</td>\n      <td>124</td>\n      <td>0.516129</td>\n      <td>0.411290</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2023.12.11~12.17</td>\n      <td>(570.0, 605.0]</td>\n      <td>77</td>\n      <td>233</td>\n      <td>63</td>\n      <td>233</td>\n      <td>0.330472</td>\n      <td>0.270386</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2023.12.11~12.17</td>\n      <td>(605.0, inf]</td>\n      <td>54</td>\n      <td>164</td>\n      <td>41</td>\n      <td>164</td>\n      <td>0.329268</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2023.12.18~12.24</td>\n      <td>(-inf, 500.0]</td>\n      <td>2</td>\n      <td>2</td>\n      <td>2</td>\n      <td>2</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2023.12.18~12.24</td>\n      <td>(500.0, 520.0]</td>\n      <td>8</td>\n      <td>14</td>\n      <td>8</td>\n      <td>14</td>\n      <td>0.571429</td>\n      <td>0.571429</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2023.12.18~12.24</td>\n      <td>(520.0, 550.0]</td>\n      <td>38</td>\n      <td>73</td>\n      <td>35</td>\n      <td>73</td>\n      <td>0.520548</td>\n      <td>0.479452</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2023.12.18~12.24</td>\n      <td>(550.0, 570.0]</td>\n      <td>37</td>\n      <td>85</td>\n      <td>32</td>\n      <td>85</td>\n      <td>0.435294</td>\n      <td>0.376471</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2023.12.18~12.24</td>\n      <td>(570.0, 605.0]</td>\n      <td>58</td>\n      <td>183</td>\n      <td>46</td>\n      <td>183</td>\n      <td>0.316940</td>\n      <td>0.251366</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2023.12.18~12.24</td>\n      <td>(605.0, inf]</td>\n      <td>18</td>\n      <td>114</td>\n      <td>13</td>\n      <td>114</td>\n      <td>0.157895</td>\n      <td>0.114035</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2023.12.25~12.31</td>\n      <td>(-inf, 500.0]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2023.12.25~12.31</td>\n      <td>(500.0, 520.0]</td>\n      <td>1</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>0.333333</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2023.12.25~12.31</td>\n      <td>(520.0, 550.0]</td>\n      <td>9</td>\n      <td>18</td>\n      <td>9</td>\n      <td>18</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2023.12.25~12.31</td>\n      <td>(550.0, 570.0]</td>\n      <td>12</td>\n      <td>30</td>\n      <td>9</td>\n      <td>30</td>\n      <td>0.400000</td>\n      <td>0.300000</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2023.12.25~12.31</td>\n      <td>(570.0, 605.0]</td>\n      <td>26</td>\n      <td>74</td>\n      <td>22</td>\n      <td>74</td>\n      <td>0.351351</td>\n      <td>0.297297</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2023.12.25~12.31</td>\n      <td>(605.0, inf]</td>\n      <td>16</td>\n      <td>46</td>\n      <td>9</td>\n      <td>46</td>\n      <td>0.347826</td>\n      <td>0.195652</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.01.01~01.07</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.01.01~01.07</td>\n      <td>(500.0, 520.0]</td>\n      <td>20</td>\n      <td>36</td>\n      <td>19</td>\n      <td>36</td>\n      <td>0.555556</td>\n      <td>0.527778</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.01.01~01.07</td>\n      <td>(520.0, 550.0]</td>\n      <td>56</td>\n      <td>94</td>\n      <td>52</td>\n      <td>94</td>\n      <td>0.595745</td>\n      <td>0.553191</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.01.01~01.07</td>\n      <td>(550.0, 570.0]</td>\n      <td>59</td>\n      <td>123</td>\n      <td>56</td>\n      <td>123</td>\n      <td>0.479675</td>\n      <td>0.455285</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.01.01~01.07</td>\n      <td>(570.0, 605.0]</td>\n      <td>94</td>\n      <td>272</td>\n      <td>80</td>\n      <td>272</td>\n      <td>0.345588</td>\n      <td>0.294118</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.01.01~01.07</td>\n      <td>(605.0, inf]</td>\n      <td>81</td>\n      <td>276</td>\n      <td>60</td>\n      <td>276</td>\n      <td>0.293478</td>\n      <td>0.217391</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.01.08~01.14</td>\n      <td>(-inf, 500.0]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.01.08~01.14</td>\n      <td>(500.0, 520.0]</td>\n      <td>15</td>\n      <td>35</td>\n      <td>14</td>\n      <td>35</td>\n      <td>0.428571</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.01.08~01.14</td>\n      <td>(520.0, 550.0]</td>\n      <td>63</td>\n      <td>101</td>\n      <td>58</td>\n      <td>101</td>\n      <td>0.623762</td>\n      <td>0.574257</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.01.08~01.14</td>\n      <td>(550.0, 570.0]</td>\n      <td>160</td>\n      <td>305</td>\n      <td>148</td>\n      <td>305</td>\n      <td>0.524590</td>\n      <td>0.485246</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.01.08~01.14</td>\n      <td>(570.0, 605.0]</td>\n      <td>150</td>\n      <td>368</td>\n      <td>136</td>\n      <td>368</td>\n      <td>0.407609</td>\n      <td>0.369565</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.01.08~01.14</td>\n      <td>(605.0, inf]</td>\n      <td>113</td>\n      <td>346</td>\n      <td>95</td>\n      <td>346</td>\n      <td>0.326590</td>\n      <td>0.274566</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.01.15~01.21</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.01.15~01.21</td>\n      <td>(500.0, 520.0]</td>\n      <td>60</td>\n      <td>94</td>\n      <td>58</td>\n      <td>94</td>\n      <td>0.638298</td>\n      <td>0.617021</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.01.15~01.21</td>\n      <td>(520.0, 550.0]</td>\n      <td>97</td>\n      <td>191</td>\n      <td>93</td>\n      <td>191</td>\n      <td>0.507853</td>\n      <td>0.486911</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.01.15~01.21</td>\n      <td>(550.0, 570.0]</td>\n      <td>66</td>\n      <td>181</td>\n      <td>58</td>\n      <td>181</td>\n      <td>0.364641</td>\n      <td>0.320442</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.01.15~01.21</td>\n      <td>(570.0, 605.0]</td>\n      <td>94</td>\n      <td>341</td>\n      <td>86</td>\n      <td>341</td>\n      <td>0.275660</td>\n      <td>0.252199</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.01.15~01.21</td>\n      <td>(605.0, inf]</td>\n      <td>66</td>\n      <td>227</td>\n      <td>48</td>\n      <td>227</td>\n      <td>0.290749</td>\n      <td>0.211454</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.01.22~01.28</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.01.22~01.28</td>\n      <td>(500.0, 520.0]</td>\n      <td>18</td>\n      <td>28</td>\n      <td>16</td>\n      <td>28</td>\n      <td>0.642857</td>\n      <td>0.571429</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.01.22~01.28</td>\n      <td>(520.0, 550.0]</td>\n      <td>98</td>\n      <td>226</td>\n      <td>88</td>\n      <td>226</td>\n      <td>0.433628</td>\n      <td>0.389381</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.01.22~01.28</td>\n      <td>(550.0, 570.0]</td>\n      <td>66</td>\n      <td>170</td>\n      <td>53</td>\n      <td>170</td>\n      <td>0.388235</td>\n      <td>0.311765</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.01.22~01.28</td>\n      <td>(570.0, 605.0]</td>\n      <td>78</td>\n      <td>283</td>\n      <td>58</td>\n      <td>283</td>\n      <td>0.275618</td>\n      <td>0.204947</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.01.22~01.28</td>\n      <td>(605.0, inf]</td>\n      <td>36</td>\n      <td>142</td>\n      <td>29</td>\n      <td>142</td>\n      <td>0.253521</td>\n      <td>0.204225</td>\n    </tr>\n    <tr>\n      <th>48</th>\n      <td>2024.01.29~02.04</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>49</th>\n      <td>2024.01.29~02.04</td>\n      <td>(500.0, 520.0]</td>\n      <td>28</td>\n      <td>47</td>\n      <td>26</td>\n      <td>47</td>\n      <td>0.595745</td>\n      <td>0.553191</td>\n    </tr>\n    <tr>\n      <th>50</th>\n      <td>2024.01.29~02.04</td>\n      <td>(520.0, 550.0]</td>\n      <td>131</td>\n      <td>306</td>\n      <td>114</td>\n      <td>306</td>\n      <td>0.428105</td>\n      <td>0.372549</td>\n    </tr>\n    <tr>\n      <th>51</th>\n      <td>2024.01.29~02.04</td>\n      <td>(550.0, 570.0]</td>\n      <td>81</td>\n      <td>240</td>\n      <td>69</td>\n      <td>240</td>\n      <td>0.337500</td>\n      <td>0.287500</td>\n    </tr>\n    <tr>\n      <th>52</th>\n      <td>2024.01.29~02.04</td>\n      <td>(570.0, 605.0]</td>\n      <td>88</td>\n      <td>366</td>\n      <td>70</td>\n      <td>366</td>\n      <td>0.240437</td>\n      <td>0.191257</td>\n    </tr>\n    <tr>\n      <th>53</th>\n      <td>2024.01.29~02.04</td>\n      <td>(605.0, inf]</td>\n      <td>50</td>\n      <td>162</td>\n      <td>42</td>\n      <td>162</td>\n      <td>0.308642</td>\n      <td>0.259259</td>\n    </tr>\n    <tr>\n      <th>54</th>\n      <td>2024.02.05~02.11</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>55</th>\n      <td>2024.02.05~02.11</td>\n      <td>(500.0, 520.0]</td>\n      <td>10</td>\n      <td>13</td>\n      <td>10</td>\n      <td>13</td>\n      <td>0.769231</td>\n      <td>0.769231</td>\n    </tr>\n    <tr>\n      <th>56</th>\n      <td>2024.02.05~02.11</td>\n      <td>(520.0, 550.0]</td>\n      <td>82</td>\n      <td>174</td>\n      <td>74</td>\n      <td>174</td>\n      <td>0.471264</td>\n      <td>0.425287</td>\n    </tr>\n    <tr>\n      <th>57</th>\n      <td>2024.02.05~02.11</td>\n      <td>(550.0, 570.0]</td>\n      <td>65</td>\n      <td>171</td>\n      <td>48</td>\n      <td>171</td>\n      <td>0.380117</td>\n      <td>0.280702</td>\n    </tr>\n    <tr>\n      <th>58</th>\n      <td>2024.02.05~02.11</td>\n      <td>(570.0, 605.0]</td>\n      <td>69</td>\n      <td>268</td>\n      <td>53</td>\n      <td>268</td>\n      <td>0.257463</td>\n      <td>0.197761</td>\n    </tr>\n    <tr>\n      <th>59</th>\n      <td>2024.02.05~02.11</td>\n      <td>(605.0, inf]</td>\n      <td>25</td>\n      <td>109</td>\n      <td>21</td>\n      <td>109</td>\n      <td>0.229358</td>\n      <td>0.192661</td>\n    </tr>\n    <tr>\n      <th>60</th>\n      <td>2024.02.12~02.18</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>61</th>\n      <td>2024.02.12~02.18</td>\n      <td>(500.0, 520.0]</td>\n      <td>2</td>\n      <td>6</td>\n      <td>2</td>\n      <td>6</td>\n      <td>0.333333</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>62</th>\n      <td>2024.02.12~02.18</td>\n      <td>(520.0, 550.0]</td>\n      <td>55</td>\n      <td>154</td>\n      <td>48</td>\n      <td>154</td>\n      <td>0.357143</td>\n      <td>0.311688</td>\n    </tr>\n    <tr>\n      <th>63</th>\n      <td>2024.02.12~02.18</td>\n      <td>(550.0, 570.0]</td>\n      <td>61</td>\n      <td>153</td>\n      <td>47</td>\n      <td>153</td>\n      <td>0.398693</td>\n      <td>0.307190</td>\n    </tr>\n    <tr>\n      <th>64</th>\n      <td>2024.02.12~02.18</td>\n      <td>(570.0, 605.0]</td>\n      <td>75</td>\n      <td>228</td>\n      <td>59</td>\n      <td>228</td>\n      <td>0.328947</td>\n      <td>0.258772</td>\n    </tr>\n    <tr>\n      <th>65</th>\n      <td>2024.02.12~02.18</td>\n      <td>(605.0, inf]</td>\n      <td>26</td>\n      <td>95</td>\n      <td>21</td>\n      <td>95</td>\n      <td>0.273684</td>\n      <td>0.221053</td>\n    </tr>\n    <tr>\n      <th>66</th>\n      <td>2024.02.19~02.25</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>67</th>\n      <td>2024.02.19~02.25</td>\n      <td>(500.0, 520.0]</td>\n      <td>6</td>\n      <td>8</td>\n      <td>6</td>\n      <td>8</td>\n      <td>0.750000</td>\n      <td>0.750000</td>\n    </tr>\n    <tr>\n      <th>68</th>\n      <td>2024.02.19~02.25</td>\n      <td>(520.0, 550.0]</td>\n      <td>62</td>\n      <td>155</td>\n      <td>52</td>\n      <td>155</td>\n      <td>0.400000</td>\n      <td>0.335484</td>\n    </tr>\n    <tr>\n      <th>69</th>\n      <td>2024.02.19~02.25</td>\n      <td>(550.0, 570.0]</td>\n      <td>65</td>\n      <td>171</td>\n      <td>49</td>\n      <td>171</td>\n      <td>0.380117</td>\n      <td>0.286550</td>\n    </tr>\n    <tr>\n      <th>70</th>\n      <td>2024.02.19~02.25</td>\n      <td>(570.0, 605.0]</td>\n      <td>80</td>\n      <td>214</td>\n      <td>65</td>\n      <td>214</td>\n      <td>0.373832</td>\n      <td>0.303738</td>\n    </tr>\n    <tr>\n      <th>71</th>\n      <td>2024.02.19~02.25</td>\n      <td>(605.0, inf]</td>\n      <td>27</td>\n      <td>94</td>\n      <td>20</td>\n      <td>94</td>\n      <td>0.287234</td>\n      <td>0.212766</td>\n    </tr>\n    <tr>\n      <th>72</th>\n      <td>2024.02.26~03.03</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>73</th>\n      <td>2024.02.26~03.03</td>\n      <td>(500.0, 520.0]</td>\n      <td>1</td>\n      <td>3</td>\n      <td>1</td>\n      <td>3</td>\n      <td>0.333333</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>74</th>\n      <td>2024.02.26~03.03</td>\n      <td>(520.0, 550.0]</td>\n      <td>53</td>\n      <td>122</td>\n      <td>48</td>\n      <td>122</td>\n      <td>0.434426</td>\n      <td>0.393443</td>\n    </tr>\n    <tr>\n      <th>75</th>\n      <td>2024.02.26~03.03</td>\n      <td>(550.0, 570.0]</td>\n      <td>53</td>\n      <td>147</td>\n      <td>42</td>\n      <td>147</td>\n      <td>0.360544</td>\n      <td>0.285714</td>\n    </tr>\n    <tr>\n      <th>76</th>\n      <td>2024.02.26~03.03</td>\n      <td>(570.0, 605.0]</td>\n      <td>62</td>\n      <td>209</td>\n      <td>52</td>\n      <td>209</td>\n      <td>0.296651</td>\n      <td>0.248804</td>\n    </tr>\n    <tr>\n      <th>77</th>\n      <td>2024.02.26~03.03</td>\n      <td>(605.0, inf]</td>\n      <td>29</td>\n      <td>100</td>\n      <td>21</td>\n      <td>100</td>\n      <td>0.290000</td>\n      <td>0.210000</td>\n    </tr>\n    <tr>\n      <th>78</th>\n      <td>2024.03.04~03.10</td>\n      <td>(-inf, 500.0]</td>\n      <td>1</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>79</th>\n      <td>2024.03.04~03.10</td>\n      <td>(500.0, 520.0]</td>\n      <td>18</td>\n      <td>49</td>\n      <td>17</td>\n      <td>49</td>\n      <td>0.367347</td>\n      <td>0.346939</td>\n    </tr>\n    <tr>\n      <th>80</th>\n      <td>2024.03.04~03.10</td>\n      <td>(520.0, 550.0]</td>\n      <td>46</td>\n      <td>127</td>\n      <td>44</td>\n      <td>127</td>\n      <td>0.362205</td>\n      <td>0.346457</td>\n    </tr>\n    <tr>\n      <th>81</th>\n      <td>2024.03.04~03.10</td>\n      <td>(550.0, 570.0]</td>\n      <td>40</td>\n      <td>127</td>\n      <td>37</td>\n      <td>127</td>\n      <td>0.314961</td>\n      <td>0.291339</td>\n    </tr>\n    <tr>\n      <th>82</th>\n      <td>2024.03.04~03.10</td>\n      <td>(570.0, 605.0]</td>\n      <td>30</td>\n      <td>126</td>\n      <td>26</td>\n      <td>126</td>\n      <td>0.238095</td>\n      <td>0.206349</td>\n    </tr>\n    <tr>\n      <th>83</th>\n      <td>2024.03.04~03.10</td>\n      <td>(605.0, inf]</td>\n      <td>18</td>\n      <td>65</td>\n      <td>15</td>\n      <td>65</td>\n      <td>0.276923</td>\n      <td>0.230769</td>\n    </tr>\n    <tr>\n      <th>84</th>\n      <td>2024.03.11~03.17</td>\n      <td>(-inf, 500.0]</td>\n      <td>6</td>\n      <td>10</td>\n      <td>6</td>\n      <td>10</td>\n      <td>0.600000</td>\n      <td>0.600000</td>\n    </tr>\n    <tr>\n      <th>85</th>\n      <td>2024.03.11~03.17</td>\n      <td>(500.0, 520.0]</td>\n      <td>98</td>\n      <td>168</td>\n      <td>94</td>\n      <td>168</td>\n      <td>0.583333</td>\n      <td>0.559524</td>\n    </tr>\n    <tr>\n      <th>86</th>\n      <td>2024.03.11~03.17</td>\n      <td>(520.0, 550.0]</td>\n      <td>132</td>\n      <td>250</td>\n      <td>122</td>\n      <td>250</td>\n      <td>0.528000</td>\n      <td>0.488000</td>\n    </tr>\n    <tr>\n      <th>87</th>\n      <td>2024.03.11~03.17</td>\n      <td>(550.0, 570.0]</td>\n      <td>58</td>\n      <td>131</td>\n      <td>46</td>\n      <td>131</td>\n      <td>0.442748</td>\n      <td>0.351145</td>\n    </tr>\n    <tr>\n      <th>88</th>\n      <td>2024.03.11~03.17</td>\n      <td>(570.0, 605.0]</td>\n      <td>37</td>\n      <td>126</td>\n      <td>30</td>\n      <td>126</td>\n      <td>0.293651</td>\n      <td>0.238095</td>\n    </tr>\n    <tr>\n      <th>89</th>\n      <td>2024.03.11~03.17</td>\n      <td>(605.0, inf]</td>\n      <td>12</td>\n      <td>43</td>\n      <td>11</td>\n      <td>43</td>\n      <td>0.279070</td>\n      <td>0.255814</td>\n    </tr>\n    <tr>\n      <th>90</th>\n      <td>2024.03.18~03.24</td>\n      <td>(-inf, 500.0]</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>4</td>\n      <td>0.750000</td>\n      <td>0.750000</td>\n    </tr>\n    <tr>\n      <th>91</th>\n      <td>2024.03.18~03.24</td>\n      <td>(500.0, 520.0]</td>\n      <td>61</td>\n      <td>115</td>\n      <td>55</td>\n      <td>115</td>\n      <td>0.530435</td>\n      <td>0.478261</td>\n    </tr>\n    <tr>\n      <th>92</th>\n      <td>2024.03.18~03.24</td>\n      <td>(520.0, 550.0]</td>\n      <td>99</td>\n      <td>197</td>\n      <td>91</td>\n      <td>197</td>\n      <td>0.502538</td>\n      <td>0.461929</td>\n    </tr>\n    <tr>\n      <th>93</th>\n      <td>2024.03.18~03.24</td>\n      <td>(550.0, 570.0]</td>\n      <td>46</td>\n      <td>95</td>\n      <td>39</td>\n      <td>95</td>\n      <td>0.484211</td>\n      <td>0.410526</td>\n    </tr>\n    <tr>\n      <th>94</th>\n      <td>2024.03.18~03.24</td>\n      <td>(570.0, 605.0]</td>\n      <td>24</td>\n      <td>75</td>\n      <td>21</td>\n      <td>75</td>\n      <td>0.320000</td>\n      <td>0.280000</td>\n    </tr>\n    <tr>\n      <th>95</th>\n      <td>2024.03.18~03.24</td>\n      <td>(605.0, inf]</td>\n      <td>14</td>\n      <td>28</td>\n      <td>10</td>\n      <td>28</td>\n      <td>0.500000</td>\n      <td>0.357143</td>\n    </tr>\n    <tr>\n      <th>96</th>\n      <td>2024.03.25~03.31</td>\n      <td>(-inf, 500.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>97</th>\n      <td>2024.03.25~03.31</td>\n      <td>(500.0, 520.0]</td>\n      <td>10</td>\n      <td>13</td>\n      <td>7</td>\n      <td>13</td>\n      <td>0.769231</td>\n      <td>0.538462</td>\n    </tr>\n    <tr>\n      <th>98</th>\n      <td>2024.03.25~03.31</td>\n      <td>(520.0, 550.0]</td>\n      <td>26</td>\n      <td>49</td>\n      <td>24</td>\n      <td>49</td>\n      <td>0.530612</td>\n      <td>0.489796</td>\n    </tr>\n    <tr>\n      <th>99</th>\n      <td>2024.03.25~03.31</td>\n      <td>(550.0, 570.0]</td>\n      <td>22</td>\n      <td>44</td>\n      <td>20</td>\n      <td>44</td>\n      <td>0.500000</td>\n      <td>0.454545</td>\n    </tr>\n    <tr>\n      <th>100</th>\n      <td>2024.03.25~03.31</td>\n      <td>(570.0, 605.0]</td>\n      <td>15</td>\n      <td>55</td>\n      <td>14</td>\n      <td>55</td>\n      <td>0.272727</td>\n      <td>0.254545</td>\n    </tr>\n    <tr>\n      <th>101</th>\n      <td>2024.03.25~03.31</td>\n      <td>(605.0, inf]</td>\n      <td>2</td>\n      <td>10</td>\n      <td>2</td>\n      <td>10</td>\n      <td>0.200000</td>\n      <td>0.200000</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev2_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:08:39.092624Z",
     "start_time": "2024-04-01T04:08:39.075514Z"
    }
   },
   "execution_count": 25
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev3"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev3_bin  def_pd1   (-inf, 576.0]       812       676   1488   \n1  scorev3_bin  def_pd1  (576.0, 610.0]      9254      4713  13967   \n2  scorev3_bin  def_pd1  (610.0, 620.0]      6392      3004   9396   \n3  scorev3_bin  def_pd1    (620.0, inf]      7267      2870  10137   \n\n   total_rate  positive_rate       woe      LIFT        KS       IV  \n0    0.042529       0.454301 -0.549424  1.411266  0.054191  0.02563  \n1    0.399194       0.337438 -0.070102  1.048237  0.054191  0.02563  \n2    0.268549       0.319711  0.010059  0.993166  0.054191  0.02563  \n3    0.289728       0.283121  0.183368  0.879503  0.054191  0.02563  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 576.0]</td>\n      <td>812</td>\n      <td>676</td>\n      <td>1488</td>\n      <td>0.042529</td>\n      <td>0.454301</td>\n      <td>-0.549424</td>\n      <td>1.411266</td>\n      <td>0.054191</td>\n      <td>0.02563</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(576.0, 610.0]</td>\n      <td>9254</td>\n      <td>4713</td>\n      <td>13967</td>\n      <td>0.399194</td>\n      <td>0.337438</td>\n      <td>-0.070102</td>\n      <td>1.048237</td>\n      <td>0.054191</td>\n      <td>0.02563</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(610.0, 620.0]</td>\n      <td>6392</td>\n      <td>3004</td>\n      <td>9396</td>\n      <td>0.268549</td>\n      <td>0.319711</td>\n      <td>0.010059</td>\n      <td>0.993166</td>\n      <td>0.054191</td>\n      <td>0.02563</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(620.0, inf]</td>\n      <td>7267</td>\n      <td>2870</td>\n      <td>10137</td>\n      <td>0.289728</td>\n      <td>0.283121</td>\n      <td>0.183368</td>\n      <td>0.879503</td>\n      <td>0.054191</td>\n      <td>0.02563</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=1) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "df['scorev3_bin'] = pd.cut(df['scorev3'],[-np.inf,576,610,620,np.inf])\n",
    "univerate(df[condition],'scorev3_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:09:51.952891Z",
     "start_time": "2024-04-01T04:09:51.896758Z"
    }
   },
   "execution_count": 26
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev3_bin  def_pd1   (-inf, 576.0]       605       465   1070   \n1  scorev3_bin  def_pd1  (576.0, 610.0]      4976      2571   7547   \n2  scorev3_bin  def_pd1  (610.0, 620.0]      2821      1441   4262   \n3  scorev3_bin  def_pd1    (620.0, inf]      3658      1483   5141   \n\n   total_rate  positive_rate       woe      LIFT        KS       IV  \n0    0.059378       0.434579 -0.434631  1.313947  0.054491  0.02395  \n1    0.418812       0.340665 -0.044387  1.029998  0.054491  0.02395  \n2    0.236515       0.338104 -0.032931  1.022255  0.054491  0.02395  \n3    0.285294       0.288465  0.197306  0.872172  0.054491  0.02395  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 576.0]</td>\n      <td>605</td>\n      <td>465</td>\n      <td>1070</td>\n      <td>0.059378</td>\n      <td>0.434579</td>\n      <td>-0.434631</td>\n      <td>1.313947</td>\n      <td>0.054491</td>\n      <td>0.02395</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(576.0, 610.0]</td>\n      <td>4976</td>\n      <td>2571</td>\n      <td>7547</td>\n      <td>0.418812</td>\n      <td>0.340665</td>\n      <td>-0.044387</td>\n      <td>1.029998</td>\n      <td>0.054491</td>\n      <td>0.02395</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(610.0, 620.0]</td>\n      <td>2821</td>\n      <td>1441</td>\n      <td>4262</td>\n      <td>0.236515</td>\n      <td>0.338104</td>\n      <td>-0.032931</td>\n      <td>1.022255</td>\n      <td>0.054491</td>\n      <td>0.02395</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(620.0, inf]</td>\n      <td>3658</td>\n      <td>1483</td>\n      <td>5141</td>\n      <td>0.285294</td>\n      <td>0.288465</td>\n      <td>0.197306</td>\n      <td>0.872172</td>\n      <td>0.054491</td>\n      <td>0.02395</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']==1) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "df['scorev3_bin'] = pd.cut(df['scorev3'],[-np.inf,576,610,620,np.inf])\n",
    "univerate(df[condition],'scorev3_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:10:17.490231Z",
     "start_time": "2024-04-01T04:10:17.450308Z"
    }
   },
   "execution_count": 28
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev3_bin  def_pd1   (-inf, 576.0]       207       211    418   \n1  scorev3_bin  def_pd1  (576.0, 610.0]      4278      2142   6420   \n2  scorev3_bin  def_pd1  (610.0, 620.0]      3571      1563   5134   \n3  scorev3_bin  def_pd1    (620.0, inf]      3609      1387   4996   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.024635       0.504785 -0.777460  1.615159  0.059228  0.029157  \n1    0.378359       0.333645 -0.096324  1.067563  0.059228  0.029157  \n2    0.302570       0.304441  0.037793  0.974119  0.059228  0.029157  \n3    0.294437       0.277622  0.167378  0.888307  0.059228  0.029157  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 576.0]</td>\n      <td>207</td>\n      <td>211</td>\n      <td>418</td>\n      <td>0.024635</td>\n      <td>0.504785</td>\n      <td>-0.777460</td>\n      <td>1.615159</td>\n      <td>0.059228</td>\n      <td>0.029157</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(576.0, 610.0]</td>\n      <td>4278</td>\n      <td>2142</td>\n      <td>6420</td>\n      <td>0.378359</td>\n      <td>0.333645</td>\n      <td>-0.096324</td>\n      <td>1.067563</td>\n      <td>0.059228</td>\n      <td>0.029157</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(610.0, 620.0]</td>\n      <td>3571</td>\n      <td>1563</td>\n      <td>5134</td>\n      <td>0.302570</td>\n      <td>0.304441</td>\n      <td>0.037793</td>\n      <td>0.974119</td>\n      <td>0.059228</td>\n      <td>0.029157</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev3_bin</td>\n      <td>def_pd1</td>\n      <td>(620.0, inf]</td>\n      <td>3609</td>\n      <td>1387</td>\n      <td>4996</td>\n      <td>0.294437</td>\n      <td>0.277622</td>\n      <td>0.167378</td>\n      <td>0.888307</td>\n      <td>0.059228</td>\n      <td>0.029157</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']==2) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "df['scorev3_bin'] = pd.cut(df['scorev3'],[-np.inf,576,610,620,np.inf])\n",
    "univerate(df[condition],'scorev3_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:10:36.862020Z",
     "start_time": "2024-04-01T04:10:36.763855Z"
    }
   },
   "execution_count": 29
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev3_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.01.08~01.14   (-inf, 576.0]        0        1        0        1   \n1   2024.01.08~01.14  (576.0, 610.0]        2        2        2        2   \n2   2024.01.08~01.14  (610.0, 620.0]        0        6        0        6   \n3   2024.01.08~01.14    (620.0, inf]        0        0        0        0   \n4   2024.01.15~01.21   (-inf, 576.0]       88      187       67      187   \n5   2024.01.15~01.21  (576.0, 610.0]      539     1286      467     1286   \n6   2024.01.15~01.21  (610.0, 620.0]      457     1301      397     1301   \n7   2024.01.15~01.21    (620.0, inf]      290     1054      188     1054   \n8   2024.01.22~01.28   (-inf, 576.0]      152      304      140      304   \n9   2024.01.22~01.28  (576.0, 610.0]      541     1277      453     1277   \n10  2024.01.22~01.28  (610.0, 620.0]      300     1051      261     1051   \n11  2024.01.22~01.28    (620.0, inf]      321     1333      236     1333   \n12  2024.01.29~02.04   (-inf, 576.0]      269      537      232      537   \n13  2024.01.29~02.04  (576.0, 610.0]      546     1348      476     1348   \n14  2024.01.29~02.04  (610.0, 620.0]      296      968      246      968   \n15  2024.01.29~02.04    (620.0, inf]      262     1105      196     1105   \n16  2024.02.05~02.11   (-inf, 576.0]       38      103       30      103   \n17  2024.02.05~02.11  (576.0, 610.0]      406     1176      334     1176   \n18  2024.02.05~02.11  (610.0, 620.0]      264     1052      240     1052   \n19  2024.02.05~02.11    (620.0, inf]      305     1265      270     1265   \n20  2024.02.12~02.18   (-inf, 576.0]       31       63       20       63   \n21  2024.02.12~02.18  (576.0, 610.0]      517     1341      374     1341   \n22  2024.02.12~02.18  (610.0, 620.0]      348     1167      297     1167   \n23  2024.02.12~02.18    (620.0, inf]      481     1398      408     1398   \n24  2024.02.19~02.25   (-inf, 576.0]       36       78       35       78   \n25  2024.02.19~02.25  (576.0, 610.0]      452     1566      333     1566   \n26  2024.02.19~02.25  (610.0, 620.0]      338      914      295      914   \n27  2024.02.19~02.25    (620.0, inf]      232      673      196      673   \n28  2024.02.26~03.03   (-inf, 576.0]       24       72       13       72   \n29  2024.02.26~03.03  (576.0, 610.0]      506     1847      347     1847   \n30  2024.02.26~03.03  (610.0, 620.0]      212      650      178      650   \n31  2024.02.26~03.03    (620.0, inf]      207      682      156      682   \n32  2024.03.04~03.10   (-inf, 576.0]       16       57       12       57   \n33  2024.03.04~03.10  (576.0, 610.0]      282     1198      218     1198   \n34  2024.03.04~03.10  (610.0, 620.0]      195      590      167      590   \n35  2024.03.04~03.10    (620.0, inf]      197      662      148      662   \n36  2024.03.11~03.17   (-inf, 576.0]       11       44       10       44   \n37  2024.03.11~03.17  (576.0, 610.0]      508     1559      395     1559   \n38  2024.03.11~03.17  (610.0, 620.0]      252      755      218      755   \n39  2024.03.11~03.17    (620.0, inf]      247      880      208      880   \n40  2024.03.18~03.24   (-inf, 576.0]       10       31       10       31   \n41  2024.03.18~03.24  (576.0, 610.0]      246      809      193      809   \n42  2024.03.18~03.24  (610.0, 620.0]      209      578      192      578   \n43  2024.03.18~03.24    (620.0, inf]      160      572      143      572   \n44  2024.03.25~03.31   (-inf, 576.0]        1       11        1       11   \n45  2024.03.25~03.31  (576.0, 610.0]      168      558      151      558   \n46  2024.03.25~03.31  (610.0, 620.0]      133      364      116      364   \n47  2024.03.25~03.31    (620.0, inf]      168      513      157      513   \n\n         pd1       cpd  \n0   0.000000  0.000000  \n1   1.000000  1.000000  \n2   0.000000  0.000000  \n3        NaN       NaN  \n4   0.470588  0.358289  \n5   0.419129  0.363142  \n6   0.351268  0.305150  \n7   0.275142  0.178368  \n8   0.500000  0.460526  \n9   0.423649  0.354738  \n10  0.285442  0.248335  \n11  0.240810  0.177044  \n12  0.500931  0.432030  \n13  0.405045  0.353116  \n14  0.305785  0.254132  \n15  0.237104  0.177376  \n16  0.368932  0.291262  \n17  0.345238  0.284014  \n18  0.250951  0.228137  \n19  0.241107  0.213439  \n20  0.492063  0.317460  \n21  0.385533  0.278896  \n22  0.298201  0.254499  \n23  0.344063  0.291845  \n24  0.461538  0.448718  \n25  0.288633  0.212644  \n26  0.369803  0.322757  \n27  0.344725  0.291233  \n28  0.333333  0.180556  \n29  0.273958  0.187872  \n30  0.326154  0.273846  \n31  0.303519  0.228739  \n32  0.280702  0.210526  \n33  0.235392  0.181970  \n34  0.330508  0.283051  \n35  0.297583  0.223565  \n36  0.250000  0.227273  \n37  0.325850  0.253368  \n38  0.333775  0.288742  \n39  0.280682  0.236364  \n40  0.322581  0.322581  \n41  0.304079  0.238566  \n42  0.361592  0.332180  \n43  0.279720  0.250000  \n44  0.090909  0.090909  \n45  0.301075  0.270609  \n46  0.365385  0.318681  \n47  0.327485  0.306043  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev3_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.01.08~01.14</td>\n      <td>(-inf, 576.0]</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.01.08~01.14</td>\n      <td>(576.0, 610.0]</td>\n      <td>2</td>\n      <td>2</td>\n      <td>2</td>\n      <td>2</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.01.08~01.14</td>\n      <td>(610.0, 620.0]</td>\n      <td>0</td>\n      <td>6</td>\n      <td>0</td>\n      <td>6</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.01.08~01.14</td>\n      <td>(620.0, inf]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.01.15~01.21</td>\n      <td>(-inf, 576.0]</td>\n      <td>88</td>\n      <td>187</td>\n      <td>67</td>\n      <td>187</td>\n      <td>0.470588</td>\n      <td>0.358289</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.01.15~01.21</td>\n      <td>(576.0, 610.0]</td>\n      <td>539</td>\n      <td>1286</td>\n      <td>467</td>\n      <td>1286</td>\n      <td>0.419129</td>\n      <td>0.363142</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.01.15~01.21</td>\n      <td>(610.0, 620.0]</td>\n      <td>457</td>\n      <td>1301</td>\n      <td>397</td>\n      <td>1301</td>\n      <td>0.351268</td>\n      <td>0.305150</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.01.15~01.21</td>\n      <td>(620.0, inf]</td>\n      <td>290</td>\n      <td>1054</td>\n      <td>188</td>\n      <td>1054</td>\n      <td>0.275142</td>\n      <td>0.178368</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.01.22~01.28</td>\n      <td>(-inf, 576.0]</td>\n      <td>152</td>\n      <td>304</td>\n      <td>140</td>\n      <td>304</td>\n      <td>0.500000</td>\n      <td>0.460526</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.01.22~01.28</td>\n      <td>(576.0, 610.0]</td>\n      <td>541</td>\n      <td>1277</td>\n      <td>453</td>\n      <td>1277</td>\n      <td>0.423649</td>\n      <td>0.354738</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.01.22~01.28</td>\n      <td>(610.0, 620.0]</td>\n      <td>300</td>\n      <td>1051</td>\n      <td>261</td>\n      <td>1051</td>\n      <td>0.285442</td>\n      <td>0.248335</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.01.22~01.28</td>\n      <td>(620.0, inf]</td>\n      <td>321</td>\n      <td>1333</td>\n      <td>236</td>\n      <td>1333</td>\n      <td>0.240810</td>\n      <td>0.177044</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.01.29~02.04</td>\n      <td>(-inf, 576.0]</td>\n      <td>269</td>\n      <td>537</td>\n      <td>232</td>\n      <td>537</td>\n      <td>0.500931</td>\n      <td>0.432030</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.01.29~02.04</td>\n      <td>(576.0, 610.0]</td>\n      <td>546</td>\n      <td>1348</td>\n      <td>476</td>\n      <td>1348</td>\n      <td>0.405045</td>\n      <td>0.353116</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.01.29~02.04</td>\n      <td>(610.0, 620.0]</td>\n      <td>296</td>\n      <td>968</td>\n      <td>246</td>\n      <td>968</td>\n      <td>0.305785</td>\n      <td>0.254132</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.01.29~02.04</td>\n      <td>(620.0, inf]</td>\n      <td>262</td>\n      <td>1105</td>\n      <td>196</td>\n      <td>1105</td>\n      <td>0.237104</td>\n      <td>0.177376</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2024.02.05~02.11</td>\n      <td>(-inf, 576.0]</td>\n      <td>38</td>\n      <td>103</td>\n      <td>30</td>\n      <td>103</td>\n      <td>0.368932</td>\n      <td>0.291262</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2024.02.05~02.11</td>\n      <td>(576.0, 610.0]</td>\n      <td>406</td>\n      <td>1176</td>\n      <td>334</td>\n      <td>1176</td>\n      <td>0.345238</td>\n      <td>0.284014</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2024.02.05~02.11</td>\n      <td>(610.0, 620.0]</td>\n      <td>264</td>\n      <td>1052</td>\n      <td>240</td>\n      <td>1052</td>\n      <td>0.250951</td>\n      <td>0.228137</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2024.02.05~02.11</td>\n      <td>(620.0, inf]</td>\n      <td>305</td>\n      <td>1265</td>\n      <td>270</td>\n      <td>1265</td>\n      <td>0.241107</td>\n      <td>0.213439</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2024.02.12~02.18</td>\n      <td>(-inf, 576.0]</td>\n      <td>31</td>\n      <td>63</td>\n      <td>20</td>\n      <td>63</td>\n      <td>0.492063</td>\n      <td>0.317460</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2024.02.12~02.18</td>\n      <td>(576.0, 610.0]</td>\n      <td>517</td>\n      <td>1341</td>\n      <td>374</td>\n      <td>1341</td>\n      <td>0.385533</td>\n      <td>0.278896</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2024.02.12~02.18</td>\n      <td>(610.0, 620.0]</td>\n      <td>348</td>\n      <td>1167</td>\n      <td>297</td>\n      <td>1167</td>\n      <td>0.298201</td>\n      <td>0.254499</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2024.02.12~02.18</td>\n      <td>(620.0, inf]</td>\n      <td>481</td>\n      <td>1398</td>\n      <td>408</td>\n      <td>1398</td>\n      <td>0.344063</td>\n      <td>0.291845</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.02.19~02.25</td>\n      <td>(-inf, 576.0]</td>\n      <td>36</td>\n      <td>78</td>\n      <td>35</td>\n      <td>78</td>\n      <td>0.461538</td>\n      <td>0.448718</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.02.19~02.25</td>\n      <td>(576.0, 610.0]</td>\n      <td>452</td>\n      <td>1566</td>\n      <td>333</td>\n      <td>1566</td>\n      <td>0.288633</td>\n      <td>0.212644</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.02.19~02.25</td>\n      <td>(610.0, 620.0]</td>\n      <td>338</td>\n      <td>914</td>\n      <td>295</td>\n      <td>914</td>\n      <td>0.369803</td>\n      <td>0.322757</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.02.19~02.25</td>\n      <td>(620.0, inf]</td>\n      <td>232</td>\n      <td>673</td>\n      <td>196</td>\n      <td>673</td>\n      <td>0.344725</td>\n      <td>0.291233</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.02.26~03.03</td>\n      <td>(-inf, 576.0]</td>\n      <td>24</td>\n      <td>72</td>\n      <td>13</td>\n      <td>72</td>\n      <td>0.333333</td>\n      <td>0.180556</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.02.26~03.03</td>\n      <td>(576.0, 610.0]</td>\n      <td>506</td>\n      <td>1847</td>\n      <td>347</td>\n      <td>1847</td>\n      <td>0.273958</td>\n      <td>0.187872</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.02.26~03.03</td>\n      <td>(610.0, 620.0]</td>\n      <td>212</td>\n      <td>650</td>\n      <td>178</td>\n      <td>650</td>\n      <td>0.326154</td>\n      <td>0.273846</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.02.26~03.03</td>\n      <td>(620.0, inf]</td>\n      <td>207</td>\n      <td>682</td>\n      <td>156</td>\n      <td>682</td>\n      <td>0.303519</td>\n      <td>0.228739</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.03.04~03.10</td>\n      <td>(-inf, 576.0]</td>\n      <td>16</td>\n      <td>57</td>\n      <td>12</td>\n      <td>57</td>\n      <td>0.280702</td>\n      <td>0.210526</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.03.04~03.10</td>\n      <td>(576.0, 610.0]</td>\n      <td>282</td>\n      <td>1198</td>\n      <td>218</td>\n      <td>1198</td>\n      <td>0.235392</td>\n      <td>0.181970</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.03.04~03.10</td>\n      <td>(610.0, 620.0]</td>\n      <td>195</td>\n      <td>590</td>\n      <td>167</td>\n      <td>590</td>\n      <td>0.330508</td>\n      <td>0.283051</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.03.04~03.10</td>\n      <td>(620.0, inf]</td>\n      <td>197</td>\n      <td>662</td>\n      <td>148</td>\n      <td>662</td>\n      <td>0.297583</td>\n      <td>0.223565</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.03.11~03.17</td>\n      <td>(-inf, 576.0]</td>\n      <td>11</td>\n      <td>44</td>\n      <td>10</td>\n      <td>44</td>\n      <td>0.250000</td>\n      <td>0.227273</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.03.11~03.17</td>\n      <td>(576.0, 610.0]</td>\n      <td>508</td>\n      <td>1559</td>\n      <td>395</td>\n      <td>1559</td>\n      <td>0.325850</td>\n      <td>0.253368</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.03.11~03.17</td>\n      <td>(610.0, 620.0]</td>\n      <td>252</td>\n      <td>755</td>\n      <td>218</td>\n      <td>755</td>\n      <td>0.333775</td>\n      <td>0.288742</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.03.11~03.17</td>\n      <td>(620.0, inf]</td>\n      <td>247</td>\n      <td>880</td>\n      <td>208</td>\n      <td>880</td>\n      <td>0.280682</td>\n      <td>0.236364</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.03.18~03.24</td>\n      <td>(-inf, 576.0]</td>\n      <td>10</td>\n      <td>31</td>\n      <td>10</td>\n      <td>31</td>\n      <td>0.322581</td>\n      <td>0.322581</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.03.18~03.24</td>\n      <td>(576.0, 610.0]</td>\n      <td>246</td>\n      <td>809</td>\n      <td>193</td>\n      <td>809</td>\n      <td>0.304079</td>\n      <td>0.238566</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.03.18~03.24</td>\n      <td>(610.0, 620.0]</td>\n      <td>209</td>\n      <td>578</td>\n      <td>192</td>\n      <td>578</td>\n      <td>0.361592</td>\n      <td>0.332180</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.03.18~03.24</td>\n      <td>(620.0, inf]</td>\n      <td>160</td>\n      <td>572</td>\n      <td>143</td>\n      <td>572</td>\n      <td>0.279720</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.03.25~03.31</td>\n      <td>(-inf, 576.0]</td>\n      <td>1</td>\n      <td>11</td>\n      <td>1</td>\n      <td>11</td>\n      <td>0.090909</td>\n      <td>0.090909</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.03.25~03.31</td>\n      <td>(576.0, 610.0]</td>\n      <td>168</td>\n      <td>558</td>\n      <td>151</td>\n      <td>558</td>\n      <td>0.301075</td>\n      <td>0.270609</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.03.25~03.31</td>\n      <td>(610.0, 620.0]</td>\n      <td>133</td>\n      <td>364</td>\n      <td>116</td>\n      <td>364</td>\n      <td>0.365385</td>\n      <td>0.318681</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.03.25~03.31</td>\n      <td>(620.0, inf]</td>\n      <td>168</td>\n      <td>513</td>\n      <td>157</td>\n      <td>513</td>\n      <td>0.327485</td>\n      <td>0.306043</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=1) & (df['scorev3']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-01-09\"))\n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev3_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:11:24.432158Z",
     "start_time": "2024-04-01T04:11:24.394408Z"
    }
   },
   "execution_count": 32
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev5"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev5_bin  def_pd1   (-inf, 550.0]       497       495    992   \n1  scorev5_bin  def_pd1  (550.0, 600.0]       716       583   1299   \n2  scorev5_bin  def_pd1  (600.0, 645.0]       612       429   1041   \n3  scorev5_bin  def_pd1  (645.0, 670.0]       189       100    289   \n4  scorev5_bin  def_pd1  (670.0, 710.0]       194        85    279   \n5  scorev5_bin  def_pd1    (710.0, inf]       187        39    226   \n\n   total_rate  positive_rate       woe      LIFT       KS        IV  \n0    0.240427       0.498992 -0.319335  1.189394  0.11629  0.119328  \n1    0.314833       0.448807 -0.118816  1.069773  0.11629  0.119328  \n2    0.252302       0.412104  0.030470  0.982288  0.11629  0.119328  \n3    0.070044       0.346021  0.307323  0.824773  0.11629  0.119328  \n4    0.067620       0.304659  0.492633  0.726184  0.11629  0.119328  \n5    0.054775       0.172566  1.212161  0.411328  0.11629  0.119328  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 550.0]</td>\n      <td>497</td>\n      <td>495</td>\n      <td>992</td>\n      <td>0.240427</td>\n      <td>0.498992</td>\n      <td>-0.319335</td>\n      <td>1.189394</td>\n      <td>0.11629</td>\n      <td>0.119328</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(550.0, 600.0]</td>\n      <td>716</td>\n      <td>583</td>\n      <td>1299</td>\n      <td>0.314833</td>\n      <td>0.448807</td>\n      <td>-0.118816</td>\n      <td>1.069773</td>\n      <td>0.11629</td>\n      <td>0.119328</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(600.0, 645.0]</td>\n      <td>612</td>\n      <td>429</td>\n      <td>1041</td>\n      <td>0.252302</td>\n      <td>0.412104</td>\n      <td>0.030470</td>\n      <td>0.982288</td>\n      <td>0.11629</td>\n      <td>0.119328</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(645.0, 670.0]</td>\n      <td>189</td>\n      <td>100</td>\n      <td>289</td>\n      <td>0.070044</td>\n      <td>0.346021</td>\n      <td>0.307323</td>\n      <td>0.824773</td>\n      <td>0.11629</td>\n      <td>0.119328</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(670.0, 710.0]</td>\n      <td>194</td>\n      <td>85</td>\n      <td>279</td>\n      <td>0.067620</td>\n      <td>0.304659</td>\n      <td>0.492633</td>\n      <td>0.726184</td>\n      <td>0.11629</td>\n      <td>0.119328</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(710.0, inf]</td>\n      <td>187</td>\n      <td>39</td>\n      <td>226</td>\n      <td>0.054775</td>\n      <td>0.172566</td>\n      <td>1.212161</td>\n      <td>0.411328</td>\n      <td>0.11629</td>\n      <td>0.119328</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='ios')&(df['new_old_user_status']==0)&(df['scorev5']>0) & (df['apply_time']>=pd.to_datetime(\"2024-01-30\"))\n",
    "df['scorev5_bin'] = pd.cut(df['scorev5'],[-np.inf,550,600,645,670,710 ,np.inf])\n",
    "univerate(df[condition],'scorev5_bin','def_pd1') "
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T07:06:32.804035Z",
     "start_time": "2024-04-01T07:06:32.764323Z"
    }
   },
   "execution_count": 34
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev5_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.02.05~02.11   (-inf, 550.0]       50       95       46       95   \n1   2024.02.05~02.11  (550.0, 600.0]       56      151       49      151   \n2   2024.02.05~02.11  (600.0, 645.0]       46      114       45      114   \n3   2024.02.05~02.11  (645.0, 670.0]       20       40       19       40   \n4   2024.02.05~02.11  (670.0, 710.0]        7       30        6       30   \n5   2024.02.05~02.11    (710.0, inf]        3       31        3       31   \n6   2024.02.12~02.18   (-inf, 550.0]       47      113       41      113   \n7   2024.02.12~02.18  (550.0, 600.0]       49      110       44      110   \n8   2024.02.12~02.18  (600.0, 645.0]       48      112       42      112   \n9   2024.02.12~02.18  (645.0, 670.0]       11       28       11       28   \n10  2024.02.12~02.18  (670.0, 710.0]       10       37        8       37   \n11  2024.02.12~02.18    (710.0, inf]        5       29        4       29   \n12  2024.02.19~02.25   (-inf, 550.0]       52      111       47      111   \n13  2024.02.19~02.25  (550.0, 600.0]       93      180       83      180   \n14  2024.02.19~02.25  (600.0, 645.0]       43      108       39      108   \n15  2024.02.19~02.25  (645.0, 670.0]        8       31        8       31   \n16  2024.02.19~02.25  (670.0, 710.0]       16       35       14       35   \n17  2024.02.19~02.25    (710.0, inf]        4       27        2       27   \n18  2024.02.26~03.03   (-inf, 550.0]       52      113       47      113   \n19  2024.02.26~03.03  (550.0, 600.0]       58      137       51      137   \n20  2024.02.26~03.03  (600.0, 645.0]       36      118       31      118   \n21  2024.02.26~03.03  (645.0, 670.0]       12       42       12       42   \n22  2024.02.26~03.03  (670.0, 710.0]        8       23        6       23   \n23  2024.02.26~03.03    (710.0, inf]        5       35        5       35   \n24  2024.03.04~03.10   (-inf, 550.0]       40      106       34      106   \n25  2024.03.04~03.10  (550.0, 600.0]       60      152       51      152   \n26  2024.03.04~03.10  (600.0, 645.0]       41      118       35      118   \n27  2024.03.04~03.10  (645.0, 670.0]       12       34       10       34   \n28  2024.03.04~03.10  (670.0, 710.0]        9       35        8       35   \n29  2024.03.04~03.10    (710.0, inf]        3       20        3       20   \n30  2024.03.11~03.17   (-inf, 550.0]       79      144       74      144   \n31  2024.03.11~03.17  (550.0, 600.0]       65      169       59      169   \n32  2024.03.11~03.17  (600.0, 645.0]       54      123       52      123   \n33  2024.03.11~03.17  (645.0, 670.0]        8       28        6       28   \n34  2024.03.11~03.17  (670.0, 710.0]        9       37        9       37   \n35  2024.03.11~03.17    (710.0, inf]        5       40        5       40   \n36  2024.03.18~03.24   (-inf, 550.0]       71      130       65      130   \n37  2024.03.18~03.24  (550.0, 600.0]       84      177       79      177   \n38  2024.03.18~03.24  (600.0, 645.0]       78      180       72      180   \n39  2024.03.18~03.24  (645.0, 670.0]        9       35        7       35   \n40  2024.03.18~03.24  (670.0, 710.0]       11       42       10       42   \n41  2024.03.18~03.24    (710.0, inf]        4       21        4       21   \n42  2024.03.25~03.31   (-inf, 550.0]      104      180       95      180   \n43  2024.03.25~03.31  (550.0, 600.0]      118      223      111      223   \n44  2024.03.25~03.31  (600.0, 645.0]       83      168       76      168   \n45  2024.03.25~03.31  (645.0, 670.0]       20       51       19       51   \n46  2024.03.25~03.31  (670.0, 710.0]       15       40       15       40   \n47  2024.03.25~03.31    (710.0, inf]       10       23       10       23   \n\n         pd1       cpd  \n0   0.526316  0.484211  \n1   0.370861  0.324503  \n2   0.403509  0.394737  \n3   0.500000  0.475000  \n4   0.233333  0.200000  \n5   0.096774  0.096774  \n6   0.415929  0.362832  \n7   0.445455  0.400000  \n8   0.428571  0.375000  \n9   0.392857  0.392857  \n10  0.270270  0.216216  \n11  0.172414  0.137931  \n12  0.468468  0.423423  \n13  0.516667  0.461111  \n14  0.398148  0.361111  \n15  0.258065  0.258065  \n16  0.457143  0.400000  \n17  0.148148  0.074074  \n18  0.460177  0.415929  \n19  0.423358  0.372263  \n20  0.305085  0.262712  \n21  0.285714  0.285714  \n22  0.347826  0.260870  \n23  0.142857  0.142857  \n24  0.377358  0.320755  \n25  0.394737  0.335526  \n26  0.347458  0.296610  \n27  0.352941  0.294118  \n28  0.257143  0.228571  \n29  0.150000  0.150000  \n30  0.548611  0.513889  \n31  0.384615  0.349112  \n32  0.439024  0.422764  \n33  0.285714  0.214286  \n34  0.243243  0.243243  \n35  0.125000  0.125000  \n36  0.546154  0.500000  \n37  0.474576  0.446328  \n38  0.433333  0.400000  \n39  0.257143  0.200000  \n40  0.261905  0.238095  \n41  0.190476  0.190476  \n42  0.577778  0.527778  \n43  0.529148  0.497758  \n44  0.494048  0.452381  \n45  0.392157  0.372549  \n46  0.375000  0.375000  \n47  0.434783  0.434783  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev5_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.02.05~02.11</td>\n      <td>(-inf, 550.0]</td>\n      <td>50</td>\n      <td>95</td>\n      <td>46</td>\n      <td>95</td>\n      <td>0.526316</td>\n      <td>0.484211</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.02.05~02.11</td>\n      <td>(550.0, 600.0]</td>\n      <td>56</td>\n      <td>151</td>\n      <td>49</td>\n      <td>151</td>\n      <td>0.370861</td>\n      <td>0.324503</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.02.05~02.11</td>\n      <td>(600.0, 645.0]</td>\n      <td>46</td>\n      <td>114</td>\n      <td>45</td>\n      <td>114</td>\n      <td>0.403509</td>\n      <td>0.394737</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.02.05~02.11</td>\n      <td>(645.0, 670.0]</td>\n      <td>20</td>\n      <td>40</td>\n      <td>19</td>\n      <td>40</td>\n      <td>0.500000</td>\n      <td>0.475000</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.02.05~02.11</td>\n      <td>(670.0, 710.0]</td>\n      <td>7</td>\n      <td>30</td>\n      <td>6</td>\n      <td>30</td>\n      <td>0.233333</td>\n      <td>0.200000</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.02.05~02.11</td>\n      <td>(710.0, inf]</td>\n      <td>3</td>\n      <td>31</td>\n      <td>3</td>\n      <td>31</td>\n      <td>0.096774</td>\n      <td>0.096774</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.02.12~02.18</td>\n      <td>(-inf, 550.0]</td>\n      <td>47</td>\n      <td>113</td>\n      <td>41</td>\n      <td>113</td>\n      <td>0.415929</td>\n      <td>0.362832</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.02.12~02.18</td>\n      <td>(550.0, 600.0]</td>\n      <td>49</td>\n      <td>110</td>\n      <td>44</td>\n      <td>110</td>\n      <td>0.445455</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.02.12~02.18</td>\n      <td>(600.0, 645.0]</td>\n      <td>48</td>\n      <td>112</td>\n      <td>42</td>\n      <td>112</td>\n      <td>0.428571</td>\n      <td>0.375000</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.02.12~02.18</td>\n      <td>(645.0, 670.0]</td>\n      <td>11</td>\n      <td>28</td>\n      <td>11</td>\n      <td>28</td>\n      <td>0.392857</td>\n      <td>0.392857</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.02.12~02.18</td>\n      <td>(670.0, 710.0]</td>\n      <td>10</td>\n      <td>37</td>\n      <td>8</td>\n      <td>37</td>\n      <td>0.270270</td>\n      <td>0.216216</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.02.12~02.18</td>\n      <td>(710.0, inf]</td>\n      <td>5</td>\n      <td>29</td>\n      <td>4</td>\n      <td>29</td>\n      <td>0.172414</td>\n      <td>0.137931</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.02.19~02.25</td>\n      <td>(-inf, 550.0]</td>\n      <td>52</td>\n      <td>111</td>\n      <td>47</td>\n      <td>111</td>\n      <td>0.468468</td>\n      <td>0.423423</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.02.19~02.25</td>\n      <td>(550.0, 600.0]</td>\n      <td>93</td>\n      <td>180</td>\n      <td>83</td>\n      <td>180</td>\n      <td>0.516667</td>\n      <td>0.461111</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.02.19~02.25</td>\n      <td>(600.0, 645.0]</td>\n      <td>43</td>\n      <td>108</td>\n      <td>39</td>\n      <td>108</td>\n      <td>0.398148</td>\n      <td>0.361111</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.02.19~02.25</td>\n      <td>(645.0, 670.0]</td>\n      <td>8</td>\n      <td>31</td>\n      <td>8</td>\n      <td>31</td>\n      <td>0.258065</td>\n      <td>0.258065</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2024.02.19~02.25</td>\n      <td>(670.0, 710.0]</td>\n      <td>16</td>\n      <td>35</td>\n      <td>14</td>\n      <td>35</td>\n      <td>0.457143</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2024.02.19~02.25</td>\n      <td>(710.0, inf]</td>\n      <td>4</td>\n      <td>27</td>\n      <td>2</td>\n      <td>27</td>\n      <td>0.148148</td>\n      <td>0.074074</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2024.02.26~03.03</td>\n      <td>(-inf, 550.0]</td>\n      <td>52</td>\n      <td>113</td>\n      <td>47</td>\n      <td>113</td>\n      <td>0.460177</td>\n      <td>0.415929</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2024.02.26~03.03</td>\n      <td>(550.0, 600.0]</td>\n      <td>58</td>\n      <td>137</td>\n      <td>51</td>\n      <td>137</td>\n      <td>0.423358</td>\n      <td>0.372263</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2024.02.26~03.03</td>\n      <td>(600.0, 645.0]</td>\n      <td>36</td>\n      <td>118</td>\n      <td>31</td>\n      <td>118</td>\n      <td>0.305085</td>\n      <td>0.262712</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2024.02.26~03.03</td>\n      <td>(645.0, 670.0]</td>\n      <td>12</td>\n      <td>42</td>\n      <td>12</td>\n      <td>42</td>\n      <td>0.285714</td>\n      <td>0.285714</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2024.02.26~03.03</td>\n      <td>(670.0, 710.0]</td>\n      <td>8</td>\n      <td>23</td>\n      <td>6</td>\n      <td>23</td>\n      <td>0.347826</td>\n      <td>0.260870</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2024.02.26~03.03</td>\n      <td>(710.0, inf]</td>\n      <td>5</td>\n      <td>35</td>\n      <td>5</td>\n      <td>35</td>\n      <td>0.142857</td>\n      <td>0.142857</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.03.04~03.10</td>\n      <td>(-inf, 550.0]</td>\n      <td>40</td>\n      <td>106</td>\n      <td>34</td>\n      <td>106</td>\n      <td>0.377358</td>\n      <td>0.320755</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.03.04~03.10</td>\n      <td>(550.0, 600.0]</td>\n      <td>60</td>\n      <td>152</td>\n      <td>51</td>\n      <td>152</td>\n      <td>0.394737</td>\n      <td>0.335526</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.03.04~03.10</td>\n      <td>(600.0, 645.0]</td>\n      <td>41</td>\n      <td>118</td>\n      <td>35</td>\n      <td>118</td>\n      <td>0.347458</td>\n      <td>0.296610</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.03.04~03.10</td>\n      <td>(645.0, 670.0]</td>\n      <td>12</td>\n      <td>34</td>\n      <td>10</td>\n      <td>34</td>\n      <td>0.352941</td>\n      <td>0.294118</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.03.04~03.10</td>\n      <td>(670.0, 710.0]</td>\n      <td>9</td>\n      <td>35</td>\n      <td>8</td>\n      <td>35</td>\n      <td>0.257143</td>\n      <td>0.228571</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.03.04~03.10</td>\n      <td>(710.0, inf]</td>\n      <td>3</td>\n      <td>20</td>\n      <td>3</td>\n      <td>20</td>\n      <td>0.150000</td>\n      <td>0.150000</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.03.11~03.17</td>\n      <td>(-inf, 550.0]</td>\n      <td>79</td>\n      <td>144</td>\n      <td>74</td>\n      <td>144</td>\n      <td>0.548611</td>\n      <td>0.513889</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.03.11~03.17</td>\n      <td>(550.0, 600.0]</td>\n      <td>65</td>\n      <td>169</td>\n      <td>59</td>\n      <td>169</td>\n      <td>0.384615</td>\n      <td>0.349112</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.03.11~03.17</td>\n      <td>(600.0, 645.0]</td>\n      <td>54</td>\n      <td>123</td>\n      <td>52</td>\n      <td>123</td>\n      <td>0.439024</td>\n      <td>0.422764</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.03.11~03.17</td>\n      <td>(645.0, 670.0]</td>\n      <td>8</td>\n      <td>28</td>\n      <td>6</td>\n      <td>28</td>\n      <td>0.285714</td>\n      <td>0.214286</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.03.11~03.17</td>\n      <td>(670.0, 710.0]</td>\n      <td>9</td>\n      <td>37</td>\n      <td>9</td>\n      <td>37</td>\n      <td>0.243243</td>\n      <td>0.243243</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.03.11~03.17</td>\n      <td>(710.0, inf]</td>\n      <td>5</td>\n      <td>40</td>\n      <td>5</td>\n      <td>40</td>\n      <td>0.125000</td>\n      <td>0.125000</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.03.18~03.24</td>\n      <td>(-inf, 550.0]</td>\n      <td>71</td>\n      <td>130</td>\n      <td>65</td>\n      <td>130</td>\n      <td>0.546154</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.03.18~03.24</td>\n      <td>(550.0, 600.0]</td>\n      <td>84</td>\n      <td>177</td>\n      <td>79</td>\n      <td>177</td>\n      <td>0.474576</td>\n      <td>0.446328</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.03.18~03.24</td>\n      <td>(600.0, 645.0]</td>\n      <td>78</td>\n      <td>180</td>\n      <td>72</td>\n      <td>180</td>\n      <td>0.433333</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.03.18~03.24</td>\n      <td>(645.0, 670.0]</td>\n      <td>9</td>\n      <td>35</td>\n      <td>7</td>\n      <td>35</td>\n      <td>0.257143</td>\n      <td>0.200000</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.03.18~03.24</td>\n      <td>(670.0, 710.0]</td>\n      <td>11</td>\n      <td>42</td>\n      <td>10</td>\n      <td>42</td>\n      <td>0.261905</td>\n      <td>0.238095</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.03.18~03.24</td>\n      <td>(710.0, inf]</td>\n      <td>4</td>\n      <td>21</td>\n      <td>4</td>\n      <td>21</td>\n      <td>0.190476</td>\n      <td>0.190476</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.03.25~03.31</td>\n      <td>(-inf, 550.0]</td>\n      <td>104</td>\n      <td>180</td>\n      <td>95</td>\n      <td>180</td>\n      <td>0.577778</td>\n      <td>0.527778</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.03.25~03.31</td>\n      <td>(550.0, 600.0]</td>\n      <td>118</td>\n      <td>223</td>\n      <td>111</td>\n      <td>223</td>\n      <td>0.529148</td>\n      <td>0.497758</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.03.25~03.31</td>\n      <td>(600.0, 645.0]</td>\n      <td>83</td>\n      <td>168</td>\n      <td>76</td>\n      <td>168</td>\n      <td>0.494048</td>\n      <td>0.452381</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.03.25~03.31</td>\n      <td>(645.0, 670.0]</td>\n      <td>20</td>\n      <td>51</td>\n      <td>19</td>\n      <td>51</td>\n      <td>0.392157</td>\n      <td>0.372549</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.03.25~03.31</td>\n      <td>(670.0, 710.0]</td>\n      <td>15</td>\n      <td>40</td>\n      <td>15</td>\n      <td>40</td>\n      <td>0.375000</td>\n      <td>0.375000</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.03.25~03.31</td>\n      <td>(710.0, inf]</td>\n      <td>10</td>\n      <td>23</td>\n      <td>10</td>\n      <td>23</td>\n      <td>0.434783</td>\n      <td>0.434783</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev5_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T07:06:34.868996Z",
     "start_time": "2024-04-01T07:06:34.856334Z"
    }
   },
   "execution_count": 35
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev5_bin  def_pd1   (-inf, 550.0]      1602      1426   3028   \n1  scorev5_bin  def_pd1  (550.0, 600.0]      2682      2034   4716   \n2  scorev5_bin  def_pd1  (600.0, 645.0]      2989      1652   4641   \n3  scorev5_bin  def_pd1  (645.0, 670.0]       899       508   1407   \n4  scorev5_bin  def_pd1  (670.0, 710.0]      1392       577   1969   \n5  scorev5_bin  def_pd1    (710.0, inf]      1963       579   2542   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.165437       0.470938 -0.412497  1.272074  0.138977  0.118022  \n1    0.257663       0.431298 -0.253784  1.165000  0.138977  0.118022  \n2    0.253565       0.355958  0.061403  0.961496  0.138977  0.118022  \n3    0.076873       0.361052  0.038987  0.975256  0.138977  0.118022  \n4    0.107578       0.293042  0.345921  0.791551  0.138977  0.118022  \n5    0.138884       0.227773  0.683842  0.615250  0.138977  0.118022  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 550.0]</td>\n      <td>1602</td>\n      <td>1426</td>\n      <td>3028</td>\n      <td>0.165437</td>\n      <td>0.470938</td>\n      <td>-0.412497</td>\n      <td>1.272074</td>\n      <td>0.138977</td>\n      <td>0.118022</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(550.0, 600.0]</td>\n      <td>2682</td>\n      <td>2034</td>\n      <td>4716</td>\n      <td>0.257663</td>\n      <td>0.431298</td>\n      <td>-0.253784</td>\n      <td>1.165000</td>\n      <td>0.138977</td>\n      <td>0.118022</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(600.0, 645.0]</td>\n      <td>2989</td>\n      <td>1652</td>\n      <td>4641</td>\n      <td>0.253565</td>\n      <td>0.355958</td>\n      <td>0.061403</td>\n      <td>0.961496</td>\n      <td>0.138977</td>\n      <td>0.118022</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(645.0, 670.0]</td>\n      <td>899</td>\n      <td>508</td>\n      <td>1407</td>\n      <td>0.076873</td>\n      <td>0.361052</td>\n      <td>0.038987</td>\n      <td>0.975256</td>\n      <td>0.138977</td>\n      <td>0.118022</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(670.0, 710.0]</td>\n      <td>1392</td>\n      <td>577</td>\n      <td>1969</td>\n      <td>0.107578</td>\n      <td>0.293042</td>\n      <td>0.345921</td>\n      <td>0.791551</td>\n      <td>0.138977</td>\n      <td>0.118022</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>scorev5_bin</td>\n      <td>def_pd1</td>\n      <td>(710.0, inf]</td>\n      <td>1963</td>\n      <td>579</td>\n      <td>2542</td>\n      <td>0.138884</td>\n      <td>0.227773</td>\n      <td>0.683842</td>\n      <td>0.615250</td>\n      <td>0.138977</td>\n      <td>0.118022</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='ios')&(df['new_old_user_status']>0)&(df['scorev5']>0) & (df['apply_time']>=pd.to_datetime(\"2024-01-30\"))\n",
    "df['scorev5_bin'] = pd.cut(df['scorev5'],[-np.inf,550,600,645,670,710 ,np.inf])\n",
    "univerate(df[condition],'scorev5_bin','def_pd1') "
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T07:01:38.281873Z",
     "start_time": "2024-04-01T07:01:38.143580Z"
    }
   },
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev5_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.02.05~02.11   (-inf, 550.0]      171      383      146      383   \n1   2024.02.05~02.11  (550.0, 600.0]      267      643      244      643   \n2   2024.02.05~02.11  (600.0, 645.0]      190      613      178      613   \n3   2024.02.05~02.11  (645.0, 670.0]       89      193       82      193   \n4   2024.02.05~02.11  (670.0, 710.0]       80      253       75      253   \n5   2024.02.05~02.11    (710.0, inf]       85      252       64      252   \n6   2024.02.12~02.18   (-inf, 550.0]      154      296      152      296   \n7   2024.02.12~02.18  (550.0, 600.0]      288      599      259      599   \n8   2024.02.12~02.18  (600.0, 645.0]      223      562      204      562   \n9   2024.02.12~02.18  (645.0, 670.0]       40      105       37      105   \n10  2024.02.12~02.18  (670.0, 710.0]       61      165       51      165   \n11  2024.02.12~02.18    (710.0, inf]       57      246       46      246   \n12  2024.02.19~02.25   (-inf, 550.0]      162      323      137      323   \n13  2024.02.19~02.25  (550.0, 600.0]      266      501      230      501   \n14  2024.02.19~02.25  (600.0, 645.0]      204      410      180      410   \n15  2024.02.19~02.25  (645.0, 670.0]       37      101       37      101   \n16  2024.02.19~02.25  (670.0, 710.0]       87      203       75      203   \n17  2024.02.19~02.25    (710.0, inf]       75      253       58      253   \n18  2024.02.26~03.03   (-inf, 550.0]      174      385      163      385   \n19  2024.02.26~03.03  (550.0, 600.0]      239      564      232      564   \n20  2024.02.26~03.03  (600.0, 645.0]      137      553      123      553   \n21  2024.02.26~03.03  (645.0, 670.0]       47      164       44      164   \n22  2024.02.26~03.03  (670.0, 710.0]       70      242       61      242   \n23  2024.02.26~03.03    (710.0, inf]       61      323       51      323   \n24  2024.03.04~03.10   (-inf, 550.0]      193      417      184      417   \n25  2024.03.04~03.10  (550.0, 600.0]      216      565      209      565   \n26  2024.03.04~03.10  (600.0, 645.0]      190      665      174      665   \n27  2024.03.04~03.10  (645.0, 670.0]       74      226       56      226   \n28  2024.03.04~03.10  (670.0, 710.0]       70      239       45      239   \n29  2024.03.04~03.10    (710.0, inf]       74      345       65      345   \n30  2024.03.11~03.17   (-inf, 550.0]      221      476      200      476   \n31  2024.03.11~03.17  (550.0, 600.0]      271      692      259      692   \n32  2024.03.11~03.17  (600.0, 645.0]      281      702      267      702   \n33  2024.03.11~03.17  (645.0, 670.0]       68      192       62      192   \n34  2024.03.11~03.17  (670.0, 710.0]       47      272       35      272   \n35  2024.03.11~03.17    (710.0, inf]       58      353       50      353   \n36  2024.03.18~03.24   (-inf, 550.0]      243      473      224      473   \n37  2024.03.18~03.24  (550.0, 600.0]      297      687      272      687   \n38  2024.03.18~03.24  (600.0, 645.0]      257      625      250      625   \n39  2024.03.18~03.24  (645.0, 670.0]       76      192       74      192   \n40  2024.03.18~03.24  (670.0, 710.0]       87      300       81      300   \n41  2024.03.18~03.24    (710.0, inf]      120      443      103      443   \n42  2024.03.25~03.31   (-inf, 550.0]      108      275       98      275   \n43  2024.03.25~03.31  (550.0, 600.0]      190      465      186      465   \n44  2024.03.25~03.31  (600.0, 645.0]      170      511      163      511   \n45  2024.03.25~03.31  (645.0, 670.0]       77      234       72      234   \n46  2024.03.25~03.31  (670.0, 710.0]       75      295       74      295   \n47  2024.03.25~03.31    (710.0, inf]       49      327       46      327   \n\n         pd1       cpd  \n0   0.446475  0.381201  \n1   0.415241  0.379471  \n2   0.309951  0.290375  \n3   0.461140  0.424870  \n4   0.316206  0.296443  \n5   0.337302  0.253968  \n6   0.520270  0.513514  \n7   0.480801  0.432387  \n8   0.396797  0.362989  \n9   0.380952  0.352381  \n10  0.369697  0.309091  \n11  0.231707  0.186992  \n12  0.501548  0.424149  \n13  0.530938  0.459082  \n14  0.497561  0.439024  \n15  0.366337  0.366337  \n16  0.428571  0.369458  \n17  0.296443  0.229249  \n18  0.451948  0.423377  \n19  0.423759  0.411348  \n20  0.247740  0.222423  \n21  0.286585  0.268293  \n22  0.289256  0.252066  \n23  0.188854  0.157895  \n24  0.462830  0.441247  \n25  0.382301  0.369912  \n26  0.285714  0.261654  \n27  0.327434  0.247788  \n28  0.292887  0.188285  \n29  0.214493  0.188406  \n30  0.464286  0.420168  \n31  0.391618  0.374277  \n32  0.400285  0.380342  \n33  0.354167  0.322917  \n34  0.172794  0.128676  \n35  0.164306  0.141643  \n36  0.513742  0.473573  \n37  0.432314  0.395924  \n38  0.411200  0.400000  \n39  0.395833  0.385417  \n40  0.290000  0.270000  \n41  0.270880  0.232506  \n42  0.392727  0.356364  \n43  0.408602  0.400000  \n44  0.332681  0.318982  \n45  0.329060  0.307692  \n46  0.254237  0.250847  \n47  0.149847  0.140673  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev5_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.02.05~02.11</td>\n      <td>(-inf, 550.0]</td>\n      <td>171</td>\n      <td>383</td>\n      <td>146</td>\n      <td>383</td>\n      <td>0.446475</td>\n      <td>0.381201</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.02.05~02.11</td>\n      <td>(550.0, 600.0]</td>\n      <td>267</td>\n      <td>643</td>\n      <td>244</td>\n      <td>643</td>\n      <td>0.415241</td>\n      <td>0.379471</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.02.05~02.11</td>\n      <td>(600.0, 645.0]</td>\n      <td>190</td>\n      <td>613</td>\n      <td>178</td>\n      <td>613</td>\n      <td>0.309951</td>\n      <td>0.290375</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.02.05~02.11</td>\n      <td>(645.0, 670.0]</td>\n      <td>89</td>\n      <td>193</td>\n      <td>82</td>\n      <td>193</td>\n      <td>0.461140</td>\n      <td>0.424870</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.02.05~02.11</td>\n      <td>(670.0, 710.0]</td>\n      <td>80</td>\n      <td>253</td>\n      <td>75</td>\n      <td>253</td>\n      <td>0.316206</td>\n      <td>0.296443</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.02.05~02.11</td>\n      <td>(710.0, inf]</td>\n      <td>85</td>\n      <td>252</td>\n      <td>64</td>\n      <td>252</td>\n      <td>0.337302</td>\n      <td>0.253968</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.02.12~02.18</td>\n      <td>(-inf, 550.0]</td>\n      <td>154</td>\n      <td>296</td>\n      <td>152</td>\n      <td>296</td>\n      <td>0.520270</td>\n      <td>0.513514</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.02.12~02.18</td>\n      <td>(550.0, 600.0]</td>\n      <td>288</td>\n      <td>599</td>\n      <td>259</td>\n      <td>599</td>\n      <td>0.480801</td>\n      <td>0.432387</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.02.12~02.18</td>\n      <td>(600.0, 645.0]</td>\n      <td>223</td>\n      <td>562</td>\n      <td>204</td>\n      <td>562</td>\n      <td>0.396797</td>\n      <td>0.362989</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.02.12~02.18</td>\n      <td>(645.0, 670.0]</td>\n      <td>40</td>\n      <td>105</td>\n      <td>37</td>\n      <td>105</td>\n      <td>0.380952</td>\n      <td>0.352381</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.02.12~02.18</td>\n      <td>(670.0, 710.0]</td>\n      <td>61</td>\n      <td>165</td>\n      <td>51</td>\n      <td>165</td>\n      <td>0.369697</td>\n      <td>0.309091</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.02.12~02.18</td>\n      <td>(710.0, inf]</td>\n      <td>57</td>\n      <td>246</td>\n      <td>46</td>\n      <td>246</td>\n      <td>0.231707</td>\n      <td>0.186992</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.02.19~02.25</td>\n      <td>(-inf, 550.0]</td>\n      <td>162</td>\n      <td>323</td>\n      <td>137</td>\n      <td>323</td>\n      <td>0.501548</td>\n      <td>0.424149</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.02.19~02.25</td>\n      <td>(550.0, 600.0]</td>\n      <td>266</td>\n      <td>501</td>\n      <td>230</td>\n      <td>501</td>\n      <td>0.530938</td>\n      <td>0.459082</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.02.19~02.25</td>\n      <td>(600.0, 645.0]</td>\n      <td>204</td>\n      <td>410</td>\n      <td>180</td>\n      <td>410</td>\n      <td>0.497561</td>\n      <td>0.439024</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.02.19~02.25</td>\n      <td>(645.0, 670.0]</td>\n      <td>37</td>\n      <td>101</td>\n      <td>37</td>\n      <td>101</td>\n      <td>0.366337</td>\n      <td>0.366337</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2024.02.19~02.25</td>\n      <td>(670.0, 710.0]</td>\n      <td>87</td>\n      <td>203</td>\n      <td>75</td>\n      <td>203</td>\n      <td>0.428571</td>\n      <td>0.369458</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2024.02.19~02.25</td>\n      <td>(710.0, inf]</td>\n      <td>75</td>\n      <td>253</td>\n      <td>58</td>\n      <td>253</td>\n      <td>0.296443</td>\n      <td>0.229249</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2024.02.26~03.03</td>\n      <td>(-inf, 550.0]</td>\n      <td>174</td>\n      <td>385</td>\n      <td>163</td>\n      <td>385</td>\n      <td>0.451948</td>\n      <td>0.423377</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2024.02.26~03.03</td>\n      <td>(550.0, 600.0]</td>\n      <td>239</td>\n      <td>564</td>\n      <td>232</td>\n      <td>564</td>\n      <td>0.423759</td>\n      <td>0.411348</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2024.02.26~03.03</td>\n      <td>(600.0, 645.0]</td>\n      <td>137</td>\n      <td>553</td>\n      <td>123</td>\n      <td>553</td>\n      <td>0.247740</td>\n      <td>0.222423</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2024.02.26~03.03</td>\n      <td>(645.0, 670.0]</td>\n      <td>47</td>\n      <td>164</td>\n      <td>44</td>\n      <td>164</td>\n      <td>0.286585</td>\n      <td>0.268293</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2024.02.26~03.03</td>\n      <td>(670.0, 710.0]</td>\n      <td>70</td>\n      <td>242</td>\n      <td>61</td>\n      <td>242</td>\n      <td>0.289256</td>\n      <td>0.252066</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2024.02.26~03.03</td>\n      <td>(710.0, inf]</td>\n      <td>61</td>\n      <td>323</td>\n      <td>51</td>\n      <td>323</td>\n      <td>0.188854</td>\n      <td>0.157895</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.03.04~03.10</td>\n      <td>(-inf, 550.0]</td>\n      <td>193</td>\n      <td>417</td>\n      <td>184</td>\n      <td>417</td>\n      <td>0.462830</td>\n      <td>0.441247</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.03.04~03.10</td>\n      <td>(550.0, 600.0]</td>\n      <td>216</td>\n      <td>565</td>\n      <td>209</td>\n      <td>565</td>\n      <td>0.382301</td>\n      <td>0.369912</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.03.04~03.10</td>\n      <td>(600.0, 645.0]</td>\n      <td>190</td>\n      <td>665</td>\n      <td>174</td>\n      <td>665</td>\n      <td>0.285714</td>\n      <td>0.261654</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.03.04~03.10</td>\n      <td>(645.0, 670.0]</td>\n      <td>74</td>\n      <td>226</td>\n      <td>56</td>\n      <td>226</td>\n      <td>0.327434</td>\n      <td>0.247788</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.03.04~03.10</td>\n      <td>(670.0, 710.0]</td>\n      <td>70</td>\n      <td>239</td>\n      <td>45</td>\n      <td>239</td>\n      <td>0.292887</td>\n      <td>0.188285</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.03.04~03.10</td>\n      <td>(710.0, inf]</td>\n      <td>74</td>\n      <td>345</td>\n      <td>65</td>\n      <td>345</td>\n      <td>0.214493</td>\n      <td>0.188406</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.03.11~03.17</td>\n      <td>(-inf, 550.0]</td>\n      <td>221</td>\n      <td>476</td>\n      <td>200</td>\n      <td>476</td>\n      <td>0.464286</td>\n      <td>0.420168</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.03.11~03.17</td>\n      <td>(550.0, 600.0]</td>\n      <td>271</td>\n      <td>692</td>\n      <td>259</td>\n      <td>692</td>\n      <td>0.391618</td>\n      <td>0.374277</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.03.11~03.17</td>\n      <td>(600.0, 645.0]</td>\n      <td>281</td>\n      <td>702</td>\n      <td>267</td>\n      <td>702</td>\n      <td>0.400285</td>\n      <td>0.380342</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.03.11~03.17</td>\n      <td>(645.0, 670.0]</td>\n      <td>68</td>\n      <td>192</td>\n      <td>62</td>\n      <td>192</td>\n      <td>0.354167</td>\n      <td>0.322917</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.03.11~03.17</td>\n      <td>(670.0, 710.0]</td>\n      <td>47</td>\n      <td>272</td>\n      <td>35</td>\n      <td>272</td>\n      <td>0.172794</td>\n      <td>0.128676</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.03.11~03.17</td>\n      <td>(710.0, inf]</td>\n      <td>58</td>\n      <td>353</td>\n      <td>50</td>\n      <td>353</td>\n      <td>0.164306</td>\n      <td>0.141643</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.03.18~03.24</td>\n      <td>(-inf, 550.0]</td>\n      <td>243</td>\n      <td>473</td>\n      <td>224</td>\n      <td>473</td>\n      <td>0.513742</td>\n      <td>0.473573</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.03.18~03.24</td>\n      <td>(550.0, 600.0]</td>\n      <td>297</td>\n      <td>687</td>\n      <td>272</td>\n      <td>687</td>\n      <td>0.432314</td>\n      <td>0.395924</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.03.18~03.24</td>\n      <td>(600.0, 645.0]</td>\n      <td>257</td>\n      <td>625</td>\n      <td>250</td>\n      <td>625</td>\n      <td>0.411200</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.03.18~03.24</td>\n      <td>(645.0, 670.0]</td>\n      <td>76</td>\n      <td>192</td>\n      <td>74</td>\n      <td>192</td>\n      <td>0.395833</td>\n      <td>0.385417</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.03.18~03.24</td>\n      <td>(670.0, 710.0]</td>\n      <td>87</td>\n      <td>300</td>\n      <td>81</td>\n      <td>300</td>\n      <td>0.290000</td>\n      <td>0.270000</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.03.18~03.24</td>\n      <td>(710.0, inf]</td>\n      <td>120</td>\n      <td>443</td>\n      <td>103</td>\n      <td>443</td>\n      <td>0.270880</td>\n      <td>0.232506</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.03.25~03.31</td>\n      <td>(-inf, 550.0]</td>\n      <td>108</td>\n      <td>275</td>\n      <td>98</td>\n      <td>275</td>\n      <td>0.392727</td>\n      <td>0.356364</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.03.25~03.31</td>\n      <td>(550.0, 600.0]</td>\n      <td>190</td>\n      <td>465</td>\n      <td>186</td>\n      <td>465</td>\n      <td>0.408602</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.03.25~03.31</td>\n      <td>(600.0, 645.0]</td>\n      <td>170</td>\n      <td>511</td>\n      <td>163</td>\n      <td>511</td>\n      <td>0.332681</td>\n      <td>0.318982</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.03.25~03.31</td>\n      <td>(645.0, 670.0]</td>\n      <td>77</td>\n      <td>234</td>\n      <td>72</td>\n      <td>234</td>\n      <td>0.329060</td>\n      <td>0.307692</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.03.25~03.31</td>\n      <td>(670.0, 710.0]</td>\n      <td>75</td>\n      <td>295</td>\n      <td>74</td>\n      <td>295</td>\n      <td>0.254237</td>\n      <td>0.250847</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.03.25~03.31</td>\n      <td>(710.0, inf]</td>\n      <td>49</td>\n      <td>327</td>\n      <td>46</td>\n      <td>327</td>\n      <td>0.149847</td>\n      <td>0.140673</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev5_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T07:03:04.642058Z",
     "start_time": "2024-04-01T07:03:04.625045Z"
    }
   },
   "execution_count": 33
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev6"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev6_bin  def_pd1   (-inf, 575.0]      3090      1740   4830   \n1  scorev6_bin  def_pd1  (575.0, 577.0]       251       100    351   \n2  scorev6_bin  def_pd1  (577.0, 580.0]       195        94    289   \n3  scorev6_bin  def_pd1  (580.0, 585.0]        47        13     60   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.873418       0.360248 -0.035584  1.023202  0.031277  0.011464  \n1    0.063472       0.284900  0.305263  0.809193  0.031277  0.011464  \n2    0.052260       0.325260  0.117500  0.923824  0.031277  0.011464  \n3    0.010850       0.216667  0.609194  0.615391  0.031277  0.011464  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev6_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 575.0]</td>\n      <td>3090</td>\n      <td>1740</td>\n      <td>4830</td>\n      <td>0.873418</td>\n      <td>0.360248</td>\n      <td>-0.035584</td>\n      <td>1.023202</td>\n      <td>0.031277</td>\n      <td>0.011464</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev6_bin</td>\n      <td>def_pd1</td>\n      <td>(575.0, 577.0]</td>\n      <td>251</td>\n      <td>100</td>\n      <td>351</td>\n      <td>0.063472</td>\n      <td>0.284900</td>\n      <td>0.305263</td>\n      <td>0.809193</td>\n      <td>0.031277</td>\n      <td>0.011464</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev6_bin</td>\n      <td>def_pd1</td>\n      <td>(577.0, 580.0]</td>\n      <td>195</td>\n      <td>94</td>\n      <td>289</td>\n      <td>0.052260</td>\n      <td>0.325260</td>\n      <td>0.117500</td>\n      <td>0.923824</td>\n      <td>0.031277</td>\n      <td>0.011464</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev6_bin</td>\n      <td>def_pd1</td>\n      <td>(580.0, 585.0]</td>\n      <td>47</td>\n      <td>13</td>\n      <td>60</td>\n      <td>0.010850</td>\n      <td>0.216667</td>\n      <td>0.609194</td>\n      <td>0.615391</td>\n      <td>0.031277</td>\n      <td>0.011464</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']>0)&(df['scorev6']>0) & (df['apply_time']>=pd.to_datetime(\"2024-02-07\"))\n",
    "df['scorev6_bin'] = pd.cut(df['scorev6'],[-np.inf,575,577,580,585,590,600 ])\n",
    "univerate(df[condition],'scorev6_bin','def_pd1') "
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:22:13.859946Z",
     "start_time": "2024-04-01T04:22:13.823664Z"
    }
   },
   "execution_count": 55
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev7"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev7_bin  def_pd1    (0.0, 541.0]        59        76    135   \n1  scorev7_bin  def_pd1  (541.0, 558.0]       146       175    321   \n2  scorev7_bin  def_pd1  (558.0, 584.0]       776       585   1361   \n3  scorev7_bin  def_pd1    (584.0, inf]       368       207    575   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.056438       0.562963 -0.501482  1.291091  0.088688  0.064432  \n1    0.134197       0.545171 -0.435187  1.250287  0.088688  0.064432  \n2    0.568980       0.429831  0.025234  0.985768  0.088688  0.064432  \n3    0.240385       0.360000  0.316735  0.825618  0.088688  0.064432  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev7_bin</td>\n      <td>def_pd1</td>\n      <td>(0.0, 541.0]</td>\n      <td>59</td>\n      <td>76</td>\n      <td>135</td>\n      <td>0.056438</td>\n      <td>0.562963</td>\n      <td>-0.501482</td>\n      <td>1.291091</td>\n      <td>0.088688</td>\n      <td>0.064432</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev7_bin</td>\n      <td>def_pd1</td>\n      <td>(541.0, 558.0]</td>\n      <td>146</td>\n      <td>175</td>\n      <td>321</td>\n      <td>0.134197</td>\n      <td>0.545171</td>\n      <td>-0.435187</td>\n      <td>1.250287</td>\n      <td>0.088688</td>\n      <td>0.064432</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev7_bin</td>\n      <td>def_pd1</td>\n      <td>(558.0, 584.0]</td>\n      <td>776</td>\n      <td>585</td>\n      <td>1361</td>\n      <td>0.568980</td>\n      <td>0.429831</td>\n      <td>0.025234</td>\n      <td>0.985768</td>\n      <td>0.088688</td>\n      <td>0.064432</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev7_bin</td>\n      <td>def_pd1</td>\n      <td>(584.0, inf]</td>\n      <td>368</td>\n      <td>207</td>\n      <td>575</td>\n      <td>0.240385</td>\n      <td>0.360000</td>\n      <td>0.316735</td>\n      <td>0.825618</td>\n      <td>0.088688</td>\n      <td>0.064432</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AL')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev7']>0) \n",
    "df['scorev7_bin'] = pd.cut(df['scorev7'],[0,541,558,584,np.inf])\n",
    "univerate(df[condition],'scorev7_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:16:17.341681Z",
     "start_time": "2024-04-01T04:16:17.308699Z"
    }
   },
   "execution_count": 44
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev7_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.01.15~01.21    (0.0, 541.0]       25       41       24       41   \n1   2024.01.15~01.21  (541.0, 558.0]       11       30        8       30   \n2   2024.01.15~01.21  (558.0, 584.0]       27       79       23       79   \n3   2024.01.15~01.21    (584.0, inf]       10       37        9       37   \n4   2024.01.22~01.28    (0.0, 541.0]       39       71       36       71   \n5   2024.01.22~01.28  (541.0, 558.0]       25       52       22       52   \n6   2024.01.22~01.28  (558.0, 584.0]       58      174       52      174   \n7   2024.01.22~01.28    (584.0, inf]       23       65       19       65   \n8   2024.01.29~02.04    (0.0, 541.0]        6       11        6       11   \n9   2024.01.29~02.04  (541.0, 558.0]       17       43       16       43   \n10  2024.01.29~02.04  (558.0, 584.0]       43      107       33      107   \n11  2024.01.29~02.04    (584.0, inf]       10       33        9       33   \n12  2024.02.05~02.11    (0.0, 541.0]        0        1        0        1   \n13  2024.02.05~02.11  (541.0, 558.0]       27       35       24       35   \n14  2024.02.05~02.11  (558.0, 584.0]       49       97       37       97   \n15  2024.02.05~02.11    (584.0, inf]       18       35       16       35   \n16  2024.02.12~02.18    (0.0, 541.0]        3        3        3        3   \n17  2024.02.12~02.18  (541.0, 558.0]       13       20       12       20   \n18  2024.02.12~02.18  (558.0, 584.0]       44      102       38      102   \n19  2024.02.12~02.18    (584.0, inf]       12       31       12       31   \n20  2024.02.19~02.25    (0.0, 541.0]        2        4        2        4   \n21  2024.02.19~02.25  (541.0, 558.0]       19       28       17       28   \n22  2024.02.19~02.25  (558.0, 584.0]       52      117       42      117   \n23  2024.02.19~02.25    (584.0, inf]       16       46       14       46   \n24  2024.02.26~03.03    (0.0, 541.0]        1        4        1        4   \n25  2024.02.26~03.03  (541.0, 558.0]       21       41       20       41   \n26  2024.02.26~03.03  (558.0, 584.0]       59      137       50      137   \n27  2024.02.26~03.03    (584.0, inf]       22       60       17       60   \n28  2024.03.04~03.10    (0.0, 541.0]        0        0        0        0   \n29  2024.03.04~03.10  (541.0, 558.0]        3       11        2       11   \n30  2024.03.04~03.10  (558.0, 584.0]       39       98       34       98   \n31  2024.03.04~03.10    (584.0, inf]       23       55       18       55   \n32  2024.03.11~03.17    (0.0, 541.0]        0        0        0        0   \n33  2024.03.11~03.17  (541.0, 558.0]       16       25       14       25   \n34  2024.03.11~03.17  (558.0, 584.0]      100      197       86      197   \n35  2024.03.11~03.17    (584.0, inf]       30       77       27       77   \n36  2024.03.18~03.24    (0.0, 541.0]        0        0        0        0   \n37  2024.03.18~03.24  (541.0, 558.0]       19       30       18       30   \n38  2024.03.18~03.24  (558.0, 584.0]       80      155       69      155   \n39  2024.03.18~03.24    (584.0, inf]       30       88       25       88   \n40  2024.03.25~03.31    (0.0, 541.0]        0        0        0        0   \n41  2024.03.25~03.31  (541.0, 558.0]        4        6        3        6   \n42  2024.03.25~03.31  (558.0, 584.0]       34       98       29       98   \n43  2024.03.25~03.31    (584.0, inf]       13       48       11       48   \n\n         pd1       cpd  \n0   0.609756  0.585366  \n1   0.366667  0.266667  \n2   0.341772  0.291139  \n3   0.270270  0.243243  \n4   0.549296  0.507042  \n5   0.480769  0.423077  \n6   0.333333  0.298851  \n7   0.353846  0.292308  \n8   0.545455  0.545455  \n9   0.395349  0.372093  \n10  0.401869  0.308411  \n11  0.303030  0.272727  \n12  0.000000  0.000000  \n13  0.771429  0.685714  \n14  0.505155  0.381443  \n15  0.514286  0.457143  \n16  1.000000  1.000000  \n17  0.650000  0.600000  \n18  0.431373  0.372549  \n19  0.387097  0.387097  \n20  0.500000  0.500000  \n21  0.678571  0.607143  \n22  0.444444  0.358974  \n23  0.347826  0.304348  \n24  0.250000  0.250000  \n25  0.512195  0.487805  \n26  0.430657  0.364964  \n27  0.366667  0.283333  \n28       NaN       NaN  \n29  0.272727  0.181818  \n30  0.397959  0.346939  \n31  0.418182  0.327273  \n32       NaN       NaN  \n33  0.640000  0.560000  \n34  0.507614  0.436548  \n35  0.389610  0.350649  \n36       NaN       NaN  \n37  0.633333  0.600000  \n38  0.516129  0.445161  \n39  0.340909  0.284091  \n40       NaN       NaN  \n41  0.666667  0.500000  \n42  0.346939  0.295918  \n43  0.270833  0.229167  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev7_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.01.15~01.21</td>\n      <td>(0.0, 541.0]</td>\n      <td>25</td>\n      <td>41</td>\n      <td>24</td>\n      <td>41</td>\n      <td>0.609756</td>\n      <td>0.585366</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.01.15~01.21</td>\n      <td>(541.0, 558.0]</td>\n      <td>11</td>\n      <td>30</td>\n      <td>8</td>\n      <td>30</td>\n      <td>0.366667</td>\n      <td>0.266667</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.01.15~01.21</td>\n      <td>(558.0, 584.0]</td>\n      <td>27</td>\n      <td>79</td>\n      <td>23</td>\n      <td>79</td>\n      <td>0.341772</td>\n      <td>0.291139</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.01.15~01.21</td>\n      <td>(584.0, inf]</td>\n      <td>10</td>\n      <td>37</td>\n      <td>9</td>\n      <td>37</td>\n      <td>0.270270</td>\n      <td>0.243243</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.01.22~01.28</td>\n      <td>(0.0, 541.0]</td>\n      <td>39</td>\n      <td>71</td>\n      <td>36</td>\n      <td>71</td>\n      <td>0.549296</td>\n      <td>0.507042</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.01.22~01.28</td>\n      <td>(541.0, 558.0]</td>\n      <td>25</td>\n      <td>52</td>\n      <td>22</td>\n      <td>52</td>\n      <td>0.480769</td>\n      <td>0.423077</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.01.22~01.28</td>\n      <td>(558.0, 584.0]</td>\n      <td>58</td>\n      <td>174</td>\n      <td>52</td>\n      <td>174</td>\n      <td>0.333333</td>\n      <td>0.298851</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.01.22~01.28</td>\n      <td>(584.0, inf]</td>\n      <td>23</td>\n      <td>65</td>\n      <td>19</td>\n      <td>65</td>\n      <td>0.353846</td>\n      <td>0.292308</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.01.29~02.04</td>\n      <td>(0.0, 541.0]</td>\n      <td>6</td>\n      <td>11</td>\n      <td>6</td>\n      <td>11</td>\n      <td>0.545455</td>\n      <td>0.545455</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.01.29~02.04</td>\n      <td>(541.0, 558.0]</td>\n      <td>17</td>\n      <td>43</td>\n      <td>16</td>\n      <td>43</td>\n      <td>0.395349</td>\n      <td>0.372093</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.01.29~02.04</td>\n      <td>(558.0, 584.0]</td>\n      <td>43</td>\n      <td>107</td>\n      <td>33</td>\n      <td>107</td>\n      <td>0.401869</td>\n      <td>0.308411</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.01.29~02.04</td>\n      <td>(584.0, inf]</td>\n      <td>10</td>\n      <td>33</td>\n      <td>9</td>\n      <td>33</td>\n      <td>0.303030</td>\n      <td>0.272727</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.02.05~02.11</td>\n      <td>(0.0, 541.0]</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.02.05~02.11</td>\n      <td>(541.0, 558.0]</td>\n      <td>27</td>\n      <td>35</td>\n      <td>24</td>\n      <td>35</td>\n      <td>0.771429</td>\n      <td>0.685714</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.02.05~02.11</td>\n      <td>(558.0, 584.0]</td>\n      <td>49</td>\n      <td>97</td>\n      <td>37</td>\n      <td>97</td>\n      <td>0.505155</td>\n      <td>0.381443</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.02.05~02.11</td>\n      <td>(584.0, inf]</td>\n      <td>18</td>\n      <td>35</td>\n      <td>16</td>\n      <td>35</td>\n      <td>0.514286</td>\n      <td>0.457143</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2024.02.12~02.18</td>\n      <td>(0.0, 541.0]</td>\n      <td>3</td>\n      <td>3</td>\n      <td>3</td>\n      <td>3</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2024.02.12~02.18</td>\n      <td>(541.0, 558.0]</td>\n      <td>13</td>\n      <td>20</td>\n      <td>12</td>\n      <td>20</td>\n      <td>0.650000</td>\n      <td>0.600000</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2024.02.12~02.18</td>\n      <td>(558.0, 584.0]</td>\n      <td>44</td>\n      <td>102</td>\n      <td>38</td>\n      <td>102</td>\n      <td>0.431373</td>\n      <td>0.372549</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2024.02.12~02.18</td>\n      <td>(584.0, inf]</td>\n      <td>12</td>\n      <td>31</td>\n      <td>12</td>\n      <td>31</td>\n      <td>0.387097</td>\n      <td>0.387097</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2024.02.19~02.25</td>\n      <td>(0.0, 541.0]</td>\n      <td>2</td>\n      <td>4</td>\n      <td>2</td>\n      <td>4</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2024.02.19~02.25</td>\n      <td>(541.0, 558.0]</td>\n      <td>19</td>\n      <td>28</td>\n      <td>17</td>\n      <td>28</td>\n      <td>0.678571</td>\n      <td>0.607143</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2024.02.19~02.25</td>\n      <td>(558.0, 584.0]</td>\n      <td>52</td>\n      <td>117</td>\n      <td>42</td>\n      <td>117</td>\n      <td>0.444444</td>\n      <td>0.358974</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2024.02.19~02.25</td>\n      <td>(584.0, inf]</td>\n      <td>16</td>\n      <td>46</td>\n      <td>14</td>\n      <td>46</td>\n      <td>0.347826</td>\n      <td>0.304348</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.02.26~03.03</td>\n      <td>(0.0, 541.0]</td>\n      <td>1</td>\n      <td>4</td>\n      <td>1</td>\n      <td>4</td>\n      <td>0.250000</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.02.26~03.03</td>\n      <td>(541.0, 558.0]</td>\n      <td>21</td>\n      <td>41</td>\n      <td>20</td>\n      <td>41</td>\n      <td>0.512195</td>\n      <td>0.487805</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.02.26~03.03</td>\n      <td>(558.0, 584.0]</td>\n      <td>59</td>\n      <td>137</td>\n      <td>50</td>\n      <td>137</td>\n      <td>0.430657</td>\n      <td>0.364964</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.02.26~03.03</td>\n      <td>(584.0, inf]</td>\n      <td>22</td>\n      <td>60</td>\n      <td>17</td>\n      <td>60</td>\n      <td>0.366667</td>\n      <td>0.283333</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.03.04~03.10</td>\n      <td>(0.0, 541.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.03.04~03.10</td>\n      <td>(541.0, 558.0]</td>\n      <td>3</td>\n      <td>11</td>\n      <td>2</td>\n      <td>11</td>\n      <td>0.272727</td>\n      <td>0.181818</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.03.04~03.10</td>\n      <td>(558.0, 584.0]</td>\n      <td>39</td>\n      <td>98</td>\n      <td>34</td>\n      <td>98</td>\n      <td>0.397959</td>\n      <td>0.346939</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.03.04~03.10</td>\n      <td>(584.0, inf]</td>\n      <td>23</td>\n      <td>55</td>\n      <td>18</td>\n      <td>55</td>\n      <td>0.418182</td>\n      <td>0.327273</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.03.11~03.17</td>\n      <td>(0.0, 541.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.03.11~03.17</td>\n      <td>(541.0, 558.0]</td>\n      <td>16</td>\n      <td>25</td>\n      <td>14</td>\n      <td>25</td>\n      <td>0.640000</td>\n      <td>0.560000</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.03.11~03.17</td>\n      <td>(558.0, 584.0]</td>\n      <td>100</td>\n      <td>197</td>\n      <td>86</td>\n      <td>197</td>\n      <td>0.507614</td>\n      <td>0.436548</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.03.11~03.17</td>\n      <td>(584.0, inf]</td>\n      <td>30</td>\n      <td>77</td>\n      <td>27</td>\n      <td>77</td>\n      <td>0.389610</td>\n      <td>0.350649</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.03.18~03.24</td>\n      <td>(0.0, 541.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.03.18~03.24</td>\n      <td>(541.0, 558.0]</td>\n      <td>19</td>\n      <td>30</td>\n      <td>18</td>\n      <td>30</td>\n      <td>0.633333</td>\n      <td>0.600000</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.03.18~03.24</td>\n      <td>(558.0, 584.0]</td>\n      <td>80</td>\n      <td>155</td>\n      <td>69</td>\n      <td>155</td>\n      <td>0.516129</td>\n      <td>0.445161</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.03.18~03.24</td>\n      <td>(584.0, inf]</td>\n      <td>30</td>\n      <td>88</td>\n      <td>25</td>\n      <td>88</td>\n      <td>0.340909</td>\n      <td>0.284091</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.03.25~03.31</td>\n      <td>(0.0, 541.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.03.25~03.31</td>\n      <td>(541.0, 558.0]</td>\n      <td>4</td>\n      <td>6</td>\n      <td>3</td>\n      <td>6</td>\n      <td>0.666667</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.03.25~03.31</td>\n      <td>(558.0, 584.0]</td>\n      <td>34</td>\n      <td>98</td>\n      <td>29</td>\n      <td>98</td>\n      <td>0.346939</td>\n      <td>0.295918</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.03.25~03.31</td>\n      <td>(584.0, inf]</td>\n      <td>13</td>\n      <td>48</td>\n      <td>11</td>\n      <td>48</td>\n      <td>0.270833</td>\n      <td>0.229167</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev7_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:16:54.695019Z",
     "start_time": "2024-04-01T04:16:54.683296Z"
    }
   },
   "execution_count": 46
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev8"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev8_bin  def_pd1    (0.0, 521.0]       132       156    288   \n1  scorev8_bin  def_pd1  (521.0, 542.0]       338       359    697   \n2  scorev8_bin  def_pd1  (542.0, 576.0]      1514      1270   2784   \n3  scorev8_bin  def_pd1  (576.0, 604.0]      1677      1309   2986   \n4  scorev8_bin  def_pd1    (604.0, inf]       616       359    975   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.037257       0.541667 -0.371068  1.212593  0.053065  0.025992  \n1    0.090168       0.515065 -0.271283  1.153041  0.053065  0.025992  \n2    0.360155       0.456178 -0.038164  1.021216  0.053065  0.025992  \n3    0.386287       0.438379  0.033647  0.981370  0.053065  0.025992  \n4    0.126132       0.368205  0.323263  0.824276  0.053065  0.025992  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev8_bin</td>\n      <td>def_pd1</td>\n      <td>(0.0, 521.0]</td>\n      <td>132</td>\n      <td>156</td>\n      <td>288</td>\n      <td>0.037257</td>\n      <td>0.541667</td>\n      <td>-0.371068</td>\n      <td>1.212593</td>\n      <td>0.053065</td>\n      <td>0.025992</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev8_bin</td>\n      <td>def_pd1</td>\n      <td>(521.0, 542.0]</td>\n      <td>338</td>\n      <td>359</td>\n      <td>697</td>\n      <td>0.090168</td>\n      <td>0.515065</td>\n      <td>-0.271283</td>\n      <td>1.153041</td>\n      <td>0.053065</td>\n      <td>0.025992</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev8_bin</td>\n      <td>def_pd1</td>\n      <td>(542.0, 576.0]</td>\n      <td>1514</td>\n      <td>1270</td>\n      <td>2784</td>\n      <td>0.360155</td>\n      <td>0.456178</td>\n      <td>-0.038164</td>\n      <td>1.021216</td>\n      <td>0.053065</td>\n      <td>0.025992</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev8_bin</td>\n      <td>def_pd1</td>\n      <td>(576.0, 604.0]</td>\n      <td>1677</td>\n      <td>1309</td>\n      <td>2986</td>\n      <td>0.386287</td>\n      <td>0.438379</td>\n      <td>0.033647</td>\n      <td>0.981370</td>\n      <td>0.053065</td>\n      <td>0.025992</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev8_bin</td>\n      <td>def_pd1</td>\n      <td>(604.0, inf]</td>\n      <td>616</td>\n      <td>359</td>\n      <td>975</td>\n      <td>0.126132</td>\n      <td>0.368205</td>\n      <td>0.323263</td>\n      <td>0.824276</td>\n      <td>0.053065</td>\n      <td>0.025992</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev8']>0) #& (df['acq_channel']=='ANDF')\n",
    "df['scorev8_bin'] = pd.cut(df['scorev8'],[0,521,542,576,604,np.inf])\n",
    "univerate(df[condition],'scorev8_bin','def_pd1') "
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T07:13:53.358063Z",
     "start_time": "2024-04-01T07:13:53.320697Z"
    }
   },
   "execution_count": 41
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev8_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.01.15~01.21    (0.0, 521.0]       38       63       35       63   \n1   2024.01.15~01.21  (521.0, 542.0]       84      142       78      142   \n2   2024.01.15~01.21  (542.0, 576.0]      171      388      161      388   \n3   2024.01.15~01.21  (576.0, 604.0]       96      281       87      281   \n4   2024.01.15~01.21    (604.0, inf]       21       68       20       68   \n5   2024.01.22~01.28    (0.0, 521.0]       72      120       64      120   \n6   2024.01.22~01.28  (521.0, 542.0]      120      243      117      243   \n7   2024.01.22~01.28  (542.0, 576.0]      301      682      283      682   \n8   2024.01.22~01.28  (576.0, 604.0]      168      424      158      424   \n9   2024.01.22~01.28    (604.0, inf]       49      137       46      137   \n10  2024.01.29~02.04    (0.0, 521.0]        4       11        4       11   \n11  2024.01.29~02.04  (521.0, 542.0]       17       34       17       34   \n12  2024.01.29~02.04  (542.0, 576.0]      101      205       92      205   \n13  2024.01.29~02.04  (576.0, 604.0]      160      366      145      366   \n14  2024.01.29~02.04    (604.0, inf]       40      104       36      104   \n15  2024.02.05~02.11    (0.0, 521.0]        1        1        1        1   \n16  2024.02.05~02.11  (521.0, 542.0]        0        0        0        0   \n17  2024.02.05~02.11  (542.0, 576.0]        3       10        2       10   \n18  2024.02.05~02.11  (576.0, 604.0]      172      366      157      366   \n19  2024.02.05~02.11    (604.0, inf]       46      118       40      118   \n20  2024.02.12~02.18    (0.0, 521.0]        0        0        0        0   \n21  2024.02.12~02.18  (521.0, 542.0]        0        0        0        0   \n22  2024.02.12~02.18  (542.0, 576.0]        0        2        0        2   \n23  2024.02.12~02.18  (576.0, 604.0]      179      351      164      351   \n24  2024.02.12~02.18    (604.0, inf]       35      102       29      102   \n25  2024.02.19~02.25    (0.0, 521.0]        0        0        0        0   \n26  2024.02.19~02.25  (521.0, 542.0]        0        0        0        0   \n27  2024.02.19~02.25  (542.0, 576.0]        0        3        0        3   \n28  2024.02.19~02.25  (576.0, 604.0]      166      339      156      339   \n29  2024.02.19~02.25    (604.0, inf]       53      116       47      116   \n30  2024.02.26~03.03    (0.0, 521.0]       25       55       24       55   \n31  2024.02.26~03.03  (521.0, 542.0]       95      184       91      184   \n32  2024.02.26~03.03  (542.0, 576.0]      233      516      217      516   \n33  2024.02.26~03.03  (576.0, 604.0]      152      310      137      310   \n34  2024.02.26~03.03    (604.0, inf]       31       96       29       96   \n35  2024.03.04~03.10    (0.0, 521.0]        9       22        8       22   \n36  2024.03.04~03.10  (521.0, 542.0]       16       46       16       46   \n37  2024.03.04~03.10  (542.0, 576.0]       88      165       83      165   \n38  2024.03.04~03.10  (576.0, 604.0]       74      157       69      157   \n39  2024.03.04~03.10    (604.0, inf]       18       60       18       60   \n40  2024.03.11~03.17    (0.0, 521.0]        3        8        2        8   \n41  2024.03.11~03.17  (521.0, 542.0]       18       30       17       30   \n42  2024.03.11~03.17  (542.0, 576.0]      163      324      153      324   \n43  2024.03.11~03.17  (576.0, 604.0]       63      152       55      152   \n44  2024.03.11~03.17    (604.0, inf]       16       72       15       72   \n45  2024.03.18~03.24    (0.0, 521.0]        1        4        1        4   \n46  2024.03.18~03.24  (521.0, 542.0]        6        9        6        9   \n47  2024.03.18~03.24  (542.0, 576.0]      139      311      133      311   \n48  2024.03.18~03.24  (576.0, 604.0]       40      133       38      133   \n49  2024.03.18~03.24    (604.0, inf]       25       49       22       49   \n50  2024.03.25~03.31    (0.0, 521.0]        3        4        3        4   \n51  2024.03.25~03.31  (521.0, 542.0]        3        9        3        9   \n52  2024.03.25~03.31  (542.0, 576.0]       71      178       66      178   \n53  2024.03.25~03.31  (576.0, 604.0]       39      107       35      107   \n54  2024.03.25~03.31    (604.0, inf]       25       53       24       53   \n\n         pd1       cpd  \n0   0.603175  0.555556  \n1   0.591549  0.549296  \n2   0.440722  0.414948  \n3   0.341637  0.309609  \n4   0.308824  0.294118  \n5   0.600000  0.533333  \n6   0.493827  0.481481  \n7   0.441349  0.414956  \n8   0.396226  0.372642  \n9   0.357664  0.335766  \n10  0.363636  0.363636  \n11  0.500000  0.500000  \n12  0.492683  0.448780  \n13  0.437158  0.396175  \n14  0.384615  0.346154  \n15  1.000000  1.000000  \n16       NaN       NaN  \n17  0.300000  0.200000  \n18  0.469945  0.428962  \n19  0.389831  0.338983  \n20       NaN       NaN  \n21       NaN       NaN  \n22  0.000000  0.000000  \n23  0.509972  0.467236  \n24  0.343137  0.284314  \n25       NaN       NaN  \n26       NaN       NaN  \n27  0.000000  0.000000  \n28  0.489676  0.460177  \n29  0.456897  0.405172  \n30  0.454545  0.436364  \n31  0.516304  0.494565  \n32  0.451550  0.420543  \n33  0.490323  0.441935  \n34  0.322917  0.302083  \n35  0.409091  0.363636  \n36  0.347826  0.347826  \n37  0.533333  0.503030  \n38  0.471338  0.439490  \n39  0.300000  0.300000  \n40  0.375000  0.250000  \n41  0.600000  0.566667  \n42  0.503086  0.472222  \n43  0.414474  0.361842  \n44  0.222222  0.208333  \n45  0.250000  0.250000  \n46  0.666667  0.666667  \n47  0.446945  0.427653  \n48  0.300752  0.285714  \n49  0.510204  0.448980  \n50  0.750000  0.750000  \n51  0.333333  0.333333  \n52  0.398876  0.370787  \n53  0.364486  0.327103  \n54  0.471698  0.452830  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev8_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.01.15~01.21</td>\n      <td>(0.0, 521.0]</td>\n      <td>38</td>\n      <td>63</td>\n      <td>35</td>\n      <td>63</td>\n      <td>0.603175</td>\n      <td>0.555556</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.01.15~01.21</td>\n      <td>(521.0, 542.0]</td>\n      <td>84</td>\n      <td>142</td>\n      <td>78</td>\n      <td>142</td>\n      <td>0.591549</td>\n      <td>0.549296</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.01.15~01.21</td>\n      <td>(542.0, 576.0]</td>\n      <td>171</td>\n      <td>388</td>\n      <td>161</td>\n      <td>388</td>\n      <td>0.440722</td>\n      <td>0.414948</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.01.15~01.21</td>\n      <td>(576.0, 604.0]</td>\n      <td>96</td>\n      <td>281</td>\n      <td>87</td>\n      <td>281</td>\n      <td>0.341637</td>\n      <td>0.309609</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.01.15~01.21</td>\n      <td>(604.0, inf]</td>\n      <td>21</td>\n      <td>68</td>\n      <td>20</td>\n      <td>68</td>\n      <td>0.308824</td>\n      <td>0.294118</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.01.22~01.28</td>\n      <td>(0.0, 521.0]</td>\n      <td>72</td>\n      <td>120</td>\n      <td>64</td>\n      <td>120</td>\n      <td>0.600000</td>\n      <td>0.533333</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.01.22~01.28</td>\n      <td>(521.0, 542.0]</td>\n      <td>120</td>\n      <td>243</td>\n      <td>117</td>\n      <td>243</td>\n      <td>0.493827</td>\n      <td>0.481481</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.01.22~01.28</td>\n      <td>(542.0, 576.0]</td>\n      <td>301</td>\n      <td>682</td>\n      <td>283</td>\n      <td>682</td>\n      <td>0.441349</td>\n      <td>0.414956</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.01.22~01.28</td>\n      <td>(576.0, 604.0]</td>\n      <td>168</td>\n      <td>424</td>\n      <td>158</td>\n      <td>424</td>\n      <td>0.396226</td>\n      <td>0.372642</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.01.22~01.28</td>\n      <td>(604.0, inf]</td>\n      <td>49</td>\n      <td>137</td>\n      <td>46</td>\n      <td>137</td>\n      <td>0.357664</td>\n      <td>0.335766</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.01.29~02.04</td>\n      <td>(0.0, 521.0]</td>\n      <td>4</td>\n      <td>11</td>\n      <td>4</td>\n      <td>11</td>\n      <td>0.363636</td>\n      <td>0.363636</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.01.29~02.04</td>\n      <td>(521.0, 542.0]</td>\n      <td>17</td>\n      <td>34</td>\n      <td>17</td>\n      <td>34</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.01.29~02.04</td>\n      <td>(542.0, 576.0]</td>\n      <td>101</td>\n      <td>205</td>\n      <td>92</td>\n      <td>205</td>\n      <td>0.492683</td>\n      <td>0.448780</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.01.29~02.04</td>\n      <td>(576.0, 604.0]</td>\n      <td>160</td>\n      <td>366</td>\n      <td>145</td>\n      <td>366</td>\n      <td>0.437158</td>\n      <td>0.396175</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.01.29~02.04</td>\n      <td>(604.0, inf]</td>\n      <td>40</td>\n      <td>104</td>\n      <td>36</td>\n      <td>104</td>\n      <td>0.384615</td>\n      <td>0.346154</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.02.05~02.11</td>\n      <td>(0.0, 521.0]</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2024.02.05~02.11</td>\n      <td>(521.0, 542.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2024.02.05~02.11</td>\n      <td>(542.0, 576.0]</td>\n      <td>3</td>\n      <td>10</td>\n      <td>2</td>\n      <td>10</td>\n      <td>0.300000</td>\n      <td>0.200000</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2024.02.05~02.11</td>\n      <td>(576.0, 604.0]</td>\n      <td>172</td>\n      <td>366</td>\n      <td>157</td>\n      <td>366</td>\n      <td>0.469945</td>\n      <td>0.428962</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2024.02.05~02.11</td>\n      <td>(604.0, inf]</td>\n      <td>46</td>\n      <td>118</td>\n      <td>40</td>\n      <td>118</td>\n      <td>0.389831</td>\n      <td>0.338983</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2024.02.12~02.18</td>\n      <td>(0.0, 521.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2024.02.12~02.18</td>\n      <td>(521.0, 542.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2024.02.12~02.18</td>\n      <td>(542.0, 576.0]</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2024.02.12~02.18</td>\n      <td>(576.0, 604.0]</td>\n      <td>179</td>\n      <td>351</td>\n      <td>164</td>\n      <td>351</td>\n      <td>0.509972</td>\n      <td>0.467236</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.02.12~02.18</td>\n      <td>(604.0, inf]</td>\n      <td>35</td>\n      <td>102</td>\n      <td>29</td>\n      <td>102</td>\n      <td>0.343137</td>\n      <td>0.284314</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.02.19~02.25</td>\n      <td>(0.0, 521.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.02.19~02.25</td>\n      <td>(521.0, 542.0]</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.02.19~02.25</td>\n      <td>(542.0, 576.0]</td>\n      <td>0</td>\n      <td>3</td>\n      <td>0</td>\n      <td>3</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.02.19~02.25</td>\n      <td>(576.0, 604.0]</td>\n      <td>166</td>\n      <td>339</td>\n      <td>156</td>\n      <td>339</td>\n      <td>0.489676</td>\n      <td>0.460177</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.02.19~02.25</td>\n      <td>(604.0, inf]</td>\n      <td>53</td>\n      <td>116</td>\n      <td>47</td>\n      <td>116</td>\n      <td>0.456897</td>\n      <td>0.405172</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.02.26~03.03</td>\n      <td>(0.0, 521.0]</td>\n      <td>25</td>\n      <td>55</td>\n      <td>24</td>\n      <td>55</td>\n      <td>0.454545</td>\n      <td>0.436364</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.02.26~03.03</td>\n      <td>(521.0, 542.0]</td>\n      <td>95</td>\n      <td>184</td>\n      <td>91</td>\n      <td>184</td>\n      <td>0.516304</td>\n      <td>0.494565</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.02.26~03.03</td>\n      <td>(542.0, 576.0]</td>\n      <td>233</td>\n      <td>516</td>\n      <td>217</td>\n      <td>516</td>\n      <td>0.451550</td>\n      <td>0.420543</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.02.26~03.03</td>\n      <td>(576.0, 604.0]</td>\n      <td>152</td>\n      <td>310</td>\n      <td>137</td>\n      <td>310</td>\n      <td>0.490323</td>\n      <td>0.441935</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.02.26~03.03</td>\n      <td>(604.0, inf]</td>\n      <td>31</td>\n      <td>96</td>\n      <td>29</td>\n      <td>96</td>\n      <td>0.322917</td>\n      <td>0.302083</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.03.04~03.10</td>\n      <td>(0.0, 521.0]</td>\n      <td>9</td>\n      <td>22</td>\n      <td>8</td>\n      <td>22</td>\n      <td>0.409091</td>\n      <td>0.363636</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.03.04~03.10</td>\n      <td>(521.0, 542.0]</td>\n      <td>16</td>\n      <td>46</td>\n      <td>16</td>\n      <td>46</td>\n      <td>0.347826</td>\n      <td>0.347826</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.03.04~03.10</td>\n      <td>(542.0, 576.0]</td>\n      <td>88</td>\n      <td>165</td>\n      <td>83</td>\n      <td>165</td>\n      <td>0.533333</td>\n      <td>0.503030</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.03.04~03.10</td>\n      <td>(576.0, 604.0]</td>\n      <td>74</td>\n      <td>157</td>\n      <td>69</td>\n      <td>157</td>\n      <td>0.471338</td>\n      <td>0.439490</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.03.04~03.10</td>\n      <td>(604.0, inf]</td>\n      <td>18</td>\n      <td>60</td>\n      <td>18</td>\n      <td>60</td>\n      <td>0.300000</td>\n      <td>0.300000</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.03.11~03.17</td>\n      <td>(0.0, 521.0]</td>\n      <td>3</td>\n      <td>8</td>\n      <td>2</td>\n      <td>8</td>\n      <td>0.375000</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.03.11~03.17</td>\n      <td>(521.0, 542.0]</td>\n      <td>18</td>\n      <td>30</td>\n      <td>17</td>\n      <td>30</td>\n      <td>0.600000</td>\n      <td>0.566667</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.03.11~03.17</td>\n      <td>(542.0, 576.0]</td>\n      <td>163</td>\n      <td>324</td>\n      <td>153</td>\n      <td>324</td>\n      <td>0.503086</td>\n      <td>0.472222</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.03.11~03.17</td>\n      <td>(576.0, 604.0]</td>\n      <td>63</td>\n      <td>152</td>\n      <td>55</td>\n      <td>152</td>\n      <td>0.414474</td>\n      <td>0.361842</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.03.11~03.17</td>\n      <td>(604.0, inf]</td>\n      <td>16</td>\n      <td>72</td>\n      <td>15</td>\n      <td>72</td>\n      <td>0.222222</td>\n      <td>0.208333</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.03.18~03.24</td>\n      <td>(0.0, 521.0]</td>\n      <td>1</td>\n      <td>4</td>\n      <td>1</td>\n      <td>4</td>\n      <td>0.250000</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.03.18~03.24</td>\n      <td>(521.0, 542.0]</td>\n      <td>6</td>\n      <td>9</td>\n      <td>6</td>\n      <td>9</td>\n      <td>0.666667</td>\n      <td>0.666667</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.03.18~03.24</td>\n      <td>(542.0, 576.0]</td>\n      <td>139</td>\n      <td>311</td>\n      <td>133</td>\n      <td>311</td>\n      <td>0.446945</td>\n      <td>0.427653</td>\n    </tr>\n    <tr>\n      <th>48</th>\n      <td>2024.03.18~03.24</td>\n      <td>(576.0, 604.0]</td>\n      <td>40</td>\n      <td>133</td>\n      <td>38</td>\n      <td>133</td>\n      <td>0.300752</td>\n      <td>0.285714</td>\n    </tr>\n    <tr>\n      <th>49</th>\n      <td>2024.03.18~03.24</td>\n      <td>(604.0, inf]</td>\n      <td>25</td>\n      <td>49</td>\n      <td>22</td>\n      <td>49</td>\n      <td>0.510204</td>\n      <td>0.448980</td>\n    </tr>\n    <tr>\n      <th>50</th>\n      <td>2024.03.25~03.31</td>\n      <td>(0.0, 521.0]</td>\n      <td>3</td>\n      <td>4</td>\n      <td>3</td>\n      <td>4</td>\n      <td>0.750000</td>\n      <td>0.750000</td>\n    </tr>\n    <tr>\n      <th>51</th>\n      <td>2024.03.25~03.31</td>\n      <td>(521.0, 542.0]</td>\n      <td>3</td>\n      <td>9</td>\n      <td>3</td>\n      <td>9</td>\n      <td>0.333333</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>52</th>\n      <td>2024.03.25~03.31</td>\n      <td>(542.0, 576.0]</td>\n      <td>71</td>\n      <td>178</td>\n      <td>66</td>\n      <td>178</td>\n      <td>0.398876</td>\n      <td>0.370787</td>\n    </tr>\n    <tr>\n      <th>53</th>\n      <td>2024.03.25~03.31</td>\n      <td>(576.0, 604.0]</td>\n      <td>39</td>\n      <td>107</td>\n      <td>35</td>\n      <td>107</td>\n      <td>0.364486</td>\n      <td>0.327103</td>\n    </tr>\n    <tr>\n      <th>54</th>\n      <td>2024.03.25~03.31</td>\n      <td>(604.0, inf]</td>\n      <td>25</td>\n      <td>53</td>\n      <td>24</td>\n      <td>53</td>\n      <td>0.471698</td>\n      <td>0.452830</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "group=['repayment_week','scorev8_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T07:13:55.578231Z",
     "start_time": "2024-04-01T07:13:55.559390Z"
    }
   },
   "execution_count": 42
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev9"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "           var   target             bin  negative  positive  total  \\\n0  scorev9_bin  def_pd1   (-inf, 521.0]       323       359    682   \n1  scorev9_bin  def_pd1  (521.0, 542.0]       762       657   1419   \n2  scorev9_bin  def_pd1  (542.0, 573.0]      1437      1258   2695   \n3  scorev9_bin  def_pd1  (573.0, 590.0]       918       669   1587   \n4  scorev9_bin  def_pd1  (590.0, 604.0]       461       313    774   \n5  scorev9_bin  def_pd1    (604.0, inf]       345       185    530   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.088721       0.526393 -0.312365  1.175932  0.066884  0.028194  \n1    0.184597       0.463002 -0.061620  1.034321  0.066884  0.028194  \n2    0.350592       0.466790 -0.076962  1.042783  0.066884  0.028194  \n3    0.206452       0.421550  0.105682  0.941719  0.066884  0.028194  \n4    0.100689       0.404393  0.175214  0.903391  0.066884  0.028194  \n5    0.068948       0.349057  0.406776  0.779773  0.066884  0.028194  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev9_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 521.0]</td>\n      <td>323</td>\n      <td>359</td>\n      <td>682</td>\n      <td>0.088721</td>\n      <td>0.526393</td>\n      <td>-0.312365</td>\n      <td>1.175932</td>\n      <td>0.066884</td>\n      <td>0.028194</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev9_bin</td>\n      <td>def_pd1</td>\n      <td>(521.0, 542.0]</td>\n      <td>762</td>\n      <td>657</td>\n      <td>1419</td>\n      <td>0.184597</td>\n      <td>0.463002</td>\n      <td>-0.061620</td>\n      <td>1.034321</td>\n      <td>0.066884</td>\n      <td>0.028194</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev9_bin</td>\n      <td>def_pd1</td>\n      <td>(542.0, 573.0]</td>\n      <td>1437</td>\n      <td>1258</td>\n      <td>2695</td>\n      <td>0.350592</td>\n      <td>0.466790</td>\n      <td>-0.076962</td>\n      <td>1.042783</td>\n      <td>0.066884</td>\n      <td>0.028194</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev9_bin</td>\n      <td>def_pd1</td>\n      <td>(573.0, 590.0]</td>\n      <td>918</td>\n      <td>669</td>\n      <td>1587</td>\n      <td>0.206452</td>\n      <td>0.421550</td>\n      <td>0.105682</td>\n      <td>0.941719</td>\n      <td>0.066884</td>\n      <td>0.028194</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev9_bin</td>\n      <td>def_pd1</td>\n      <td>(590.0, 604.0]</td>\n      <td>461</td>\n      <td>313</td>\n      <td>774</td>\n      <td>0.100689</td>\n      <td>0.404393</td>\n      <td>0.175214</td>\n      <td>0.903391</td>\n      <td>0.066884</td>\n      <td>0.028194</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>scorev9_bin</td>\n      <td>def_pd1</td>\n      <td>(604.0, inf]</td>\n      <td>345</td>\n      <td>185</td>\n      <td>530</td>\n      <td>0.068948</td>\n      <td>0.349057</td>\n      <td>0.406776</td>\n      <td>0.779773</td>\n      <td>0.066884</td>\n      <td>0.028194</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev9']>0)\n",
    "df['scorev9_bin'] = pd.cut(df['scorev9'],[-np.inf,521,542,573,590,604,np.inf])\n",
    "univerate(df[condition],'scorev9_bin','def_pd1') "
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:20:08.861486Z",
     "start_time": "2024-04-01T04:20:08.824403Z"
    }
   },
   "execution_count": 51
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week     scorev9_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.01.15~01.21   (-inf, 521.0]       37       65       35       65   \n1   2024.01.15~01.21  (521.0, 542.0]       76      146       71      146   \n2   2024.01.15~01.21  (542.0, 573.0]      179      407      166      407   \n3   2024.01.15~01.21  (573.0, 590.0]       75      191       69      191   \n4   2024.01.15~01.21  (590.0, 604.0]       24       66       22       66   \n5   2024.01.15~01.21    (604.0, inf]       19       67       18       67   \n6   2024.01.22~01.28   (-inf, 521.0]       88      148       83      148   \n7   2024.01.22~01.28  (521.0, 542.0]      140      277      130      277   \n8   2024.01.22~01.28  (542.0, 573.0]      326      719      310      719   \n9   2024.01.22~01.28  (573.0, 590.0]       99      286       90      286   \n10  2024.01.22~01.28  (590.0, 604.0]       35      106       33      106   \n11  2024.01.22~01.28    (604.0, inf]       22       70       22       70   \n12  2024.01.29~02.04   (-inf, 521.0]       11       28       11       28   \n13  2024.01.29~02.04  (521.0, 542.0]       35       75       34       75   \n14  2024.01.29~02.04  (542.0, 573.0]      129      294      112      294   \n15  2024.01.29~02.04  (573.0, 590.0]       88      179       83      179   \n16  2024.01.29~02.04  (590.0, 604.0]       43       90       39       90   \n17  2024.01.29~02.04    (604.0, inf]       16       54       15       54   \n18  2024.02.05~02.11   (-inf, 521.0]        2        2        1        2   \n19  2024.02.05~02.11  (521.0, 542.0]        2        6        2        6   \n20  2024.02.05~02.11  (542.0, 573.0]       80      163       74      163   \n21  2024.02.05~02.11  (573.0, 590.0]       75      166       67      166   \n22  2024.02.05~02.11  (590.0, 604.0]       40       96       35       96   \n23  2024.02.05~02.11    (604.0, inf]       23       62       21       62   \n24  2024.02.12~02.18   (-inf, 521.0]        0        1        0        1   \n25  2024.02.12~02.18  (521.0, 542.0]        6       13        5       13   \n26  2024.02.12~02.18  (542.0, 573.0]       81      137       75      137   \n27  2024.02.12~02.18  (573.0, 590.0]       57      141       50      141   \n28  2024.02.12~02.18  (590.0, 604.0]       50       98       47       98   \n29  2024.02.12~02.18    (604.0, inf]       20       65       16       65   \n30  2024.02.19~02.25   (-inf, 521.0]        1        2        0        2   \n31  2024.02.19~02.25  (521.0, 542.0]        8       16        8       16   \n32  2024.02.19~02.25  (542.0, 573.0]       75      137       71      137   \n33  2024.02.19~02.25  (573.0, 590.0]       80      161       72      161   \n34  2024.02.19~02.25  (590.0, 604.0]       30       76       28       76   \n35  2024.02.19~02.25    (604.0, inf]       25       66       24       66   \n36  2024.02.26~03.03   (-inf, 521.0]      146      292      141      292   \n37  2024.02.26~03.03  (521.0, 542.0]      180      405      166      405   \n38  2024.02.26~03.03  (542.0, 573.0]       99      206       93      206   \n39  2024.02.26~03.03  (573.0, 590.0]       60      140       55      140   \n40  2024.02.26~03.03  (590.0, 604.0]       36       82       31       82   \n41  2024.02.26~03.03    (604.0, inf]       15       36       12       36   \n42  2024.03.04~03.10   (-inf, 521.0]       19       46       18       46   \n43  2024.03.04~03.10  (521.0, 542.0]       40       81       38       81   \n44  2024.03.04~03.10  (542.0, 573.0]       77      155       74      155   \n45  2024.03.04~03.10  (573.0, 590.0]       41       92       37       92   \n46  2024.03.04~03.10  (590.0, 604.0]       13       41       12       41   \n47  2024.03.04~03.10    (604.0, inf]       15       35       15       35   \n48  2024.03.11~03.17   (-inf, 521.0]       28       49       24       49   \n49  2024.03.11~03.17  (521.0, 542.0]       69      164       66      164   \n50  2024.03.11~03.17  (542.0, 573.0]       96      198       89      198   \n51  2024.03.11~03.17  (573.0, 590.0]       42       93       37       93   \n52  2024.03.11~03.17  (590.0, 604.0]       17       50       15       50   \n53  2024.03.11~03.17    (604.0, inf]       11       32       11       32   \n54  2024.03.18~03.24   (-inf, 521.0]       17       33       17       33   \n55  2024.03.18~03.24  (521.0, 542.0]       71      160       70      160   \n56  2024.03.18~03.24  (542.0, 573.0]       73      174       67      174   \n57  2024.03.18~03.24  (573.0, 590.0]       28       78       26       78   \n58  2024.03.18~03.24  (590.0, 604.0]       11       36       10       36   \n59  2024.03.18~03.24    (604.0, inf]       11       25       10       25   \n60  2024.03.25~03.31   (-inf, 521.0]       10       16       10       16   \n61  2024.03.25~03.31  (521.0, 542.0]       30       76       27       76   \n62  2024.03.25~03.31  (542.0, 573.0]       43      105       40      105   \n63  2024.03.25~03.31  (573.0, 590.0]       24       60       23       60   \n64  2024.03.25~03.31  (590.0, 604.0]       14       33       13       33   \n65  2024.03.25~03.31    (604.0, inf]        8       18        7       18   \n\n         pd1       cpd  \n0   0.569231  0.538462  \n1   0.520548  0.486301  \n2   0.439803  0.407862  \n3   0.392670  0.361257  \n4   0.363636  0.333333  \n5   0.283582  0.268657  \n6   0.594595  0.560811  \n7   0.505415  0.469314  \n8   0.453408  0.431154  \n9   0.346154  0.314685  \n10  0.330189  0.311321  \n11  0.314286  0.314286  \n12  0.392857  0.392857  \n13  0.466667  0.453333  \n14  0.438776  0.380952  \n15  0.491620  0.463687  \n16  0.477778  0.433333  \n17  0.296296  0.277778  \n18  1.000000  0.500000  \n19  0.333333  0.333333  \n20  0.490798  0.453988  \n21  0.451807  0.403614  \n22  0.416667  0.364583  \n23  0.370968  0.338710  \n24  0.000000  0.000000  \n25  0.461538  0.384615  \n26  0.591241  0.547445  \n27  0.404255  0.354610  \n28  0.510204  0.479592  \n29  0.307692  0.246154  \n30  0.500000  0.000000  \n31  0.500000  0.500000  \n32  0.547445  0.518248  \n33  0.496894  0.447205  \n34  0.394737  0.368421  \n35  0.378788  0.363636  \n36  0.500000  0.482877  \n37  0.444444  0.409877  \n38  0.480583  0.451456  \n39  0.428571  0.392857  \n40  0.439024  0.378049  \n41  0.416667  0.333333  \n42  0.413043  0.391304  \n43  0.493827  0.469136  \n44  0.496774  0.477419  \n45  0.445652  0.402174  \n46  0.317073  0.292683  \n47  0.428571  0.428571  \n48  0.571429  0.489796  \n49  0.420732  0.402439  \n50  0.484848  0.449495  \n51  0.451613  0.397849  \n52  0.340000  0.300000  \n53  0.343750  0.343750  \n54  0.515152  0.515152  \n55  0.443750  0.437500  \n56  0.419540  0.385057  \n57  0.358974  0.333333  \n58  0.305556  0.277778  \n59  0.440000  0.400000  \n60  0.625000  0.625000  \n61  0.394737  0.355263  \n62  0.409524  0.380952  \n63  0.400000  0.383333  \n64  0.424242  0.393939  \n65  0.444444  0.388889  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev9_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.01.15~01.21</td>\n      <td>(-inf, 521.0]</td>\n      <td>37</td>\n      <td>65</td>\n      <td>35</td>\n      <td>65</td>\n      <td>0.569231</td>\n      <td>0.538462</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.01.15~01.21</td>\n      <td>(521.0, 542.0]</td>\n      <td>76</td>\n      <td>146</td>\n      <td>71</td>\n      <td>146</td>\n      <td>0.520548</td>\n      <td>0.486301</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.01.15~01.21</td>\n      <td>(542.0, 573.0]</td>\n      <td>179</td>\n      <td>407</td>\n      <td>166</td>\n      <td>407</td>\n      <td>0.439803</td>\n      <td>0.407862</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.01.15~01.21</td>\n      <td>(573.0, 590.0]</td>\n      <td>75</td>\n      <td>191</td>\n      <td>69</td>\n      <td>191</td>\n      <td>0.392670</td>\n      <td>0.361257</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.01.15~01.21</td>\n      <td>(590.0, 604.0]</td>\n      <td>24</td>\n      <td>66</td>\n      <td>22</td>\n      <td>66</td>\n      <td>0.363636</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.01.15~01.21</td>\n      <td>(604.0, inf]</td>\n      <td>19</td>\n      <td>67</td>\n      <td>18</td>\n      <td>67</td>\n      <td>0.283582</td>\n      <td>0.268657</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.01.22~01.28</td>\n      <td>(-inf, 521.0]</td>\n      <td>88</td>\n      <td>148</td>\n      <td>83</td>\n      <td>148</td>\n      <td>0.594595</td>\n      <td>0.560811</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.01.22~01.28</td>\n      <td>(521.0, 542.0]</td>\n      <td>140</td>\n      <td>277</td>\n      <td>130</td>\n      <td>277</td>\n      <td>0.505415</td>\n      <td>0.469314</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.01.22~01.28</td>\n      <td>(542.0, 573.0]</td>\n      <td>326</td>\n      <td>719</td>\n      <td>310</td>\n      <td>719</td>\n      <td>0.453408</td>\n      <td>0.431154</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.01.22~01.28</td>\n      <td>(573.0, 590.0]</td>\n      <td>99</td>\n      <td>286</td>\n      <td>90</td>\n      <td>286</td>\n      <td>0.346154</td>\n      <td>0.314685</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.01.22~01.28</td>\n      <td>(590.0, 604.0]</td>\n      <td>35</td>\n      <td>106</td>\n      <td>33</td>\n      <td>106</td>\n      <td>0.330189</td>\n      <td>0.311321</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.01.22~01.28</td>\n      <td>(604.0, inf]</td>\n      <td>22</td>\n      <td>70</td>\n      <td>22</td>\n      <td>70</td>\n      <td>0.314286</td>\n      <td>0.314286</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.01.29~02.04</td>\n      <td>(-inf, 521.0]</td>\n      <td>11</td>\n      <td>28</td>\n      <td>11</td>\n      <td>28</td>\n      <td>0.392857</td>\n      <td>0.392857</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.01.29~02.04</td>\n      <td>(521.0, 542.0]</td>\n      <td>35</td>\n      <td>75</td>\n      <td>34</td>\n      <td>75</td>\n      <td>0.466667</td>\n      <td>0.453333</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.01.29~02.04</td>\n      <td>(542.0, 573.0]</td>\n      <td>129</td>\n      <td>294</td>\n      <td>112</td>\n      <td>294</td>\n      <td>0.438776</td>\n      <td>0.380952</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.01.29~02.04</td>\n      <td>(573.0, 590.0]</td>\n      <td>88</td>\n      <td>179</td>\n      <td>83</td>\n      <td>179</td>\n      <td>0.491620</td>\n      <td>0.463687</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>2024.01.29~02.04</td>\n      <td>(590.0, 604.0]</td>\n      <td>43</td>\n      <td>90</td>\n      <td>39</td>\n      <td>90</td>\n      <td>0.477778</td>\n      <td>0.433333</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>2024.01.29~02.04</td>\n      <td>(604.0, inf]</td>\n      <td>16</td>\n      <td>54</td>\n      <td>15</td>\n      <td>54</td>\n      <td>0.296296</td>\n      <td>0.277778</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>2024.02.05~02.11</td>\n      <td>(-inf, 521.0]</td>\n      <td>2</td>\n      <td>2</td>\n      <td>1</td>\n      <td>2</td>\n      <td>1.000000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>2024.02.05~02.11</td>\n      <td>(521.0, 542.0]</td>\n      <td>2</td>\n      <td>6</td>\n      <td>2</td>\n      <td>6</td>\n      <td>0.333333</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>2024.02.05~02.11</td>\n      <td>(542.0, 573.0]</td>\n      <td>80</td>\n      <td>163</td>\n      <td>74</td>\n      <td>163</td>\n      <td>0.490798</td>\n      <td>0.453988</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>2024.02.05~02.11</td>\n      <td>(573.0, 590.0]</td>\n      <td>75</td>\n      <td>166</td>\n      <td>67</td>\n      <td>166</td>\n      <td>0.451807</td>\n      <td>0.403614</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>2024.02.05~02.11</td>\n      <td>(590.0, 604.0]</td>\n      <td>40</td>\n      <td>96</td>\n      <td>35</td>\n      <td>96</td>\n      <td>0.416667</td>\n      <td>0.364583</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>2024.02.05~02.11</td>\n      <td>(604.0, inf]</td>\n      <td>23</td>\n      <td>62</td>\n      <td>21</td>\n      <td>62</td>\n      <td>0.370968</td>\n      <td>0.338710</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>2024.02.12~02.18</td>\n      <td>(-inf, 521.0]</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>2024.02.12~02.18</td>\n      <td>(521.0, 542.0]</td>\n      <td>6</td>\n      <td>13</td>\n      <td>5</td>\n      <td>13</td>\n      <td>0.461538</td>\n      <td>0.384615</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>2024.02.12~02.18</td>\n      <td>(542.0, 573.0]</td>\n      <td>81</td>\n      <td>137</td>\n      <td>75</td>\n      <td>137</td>\n      <td>0.591241</td>\n      <td>0.547445</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>2024.02.12~02.18</td>\n      <td>(573.0, 590.0]</td>\n      <td>57</td>\n      <td>141</td>\n      <td>50</td>\n      <td>141</td>\n      <td>0.404255</td>\n      <td>0.354610</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>2024.02.12~02.18</td>\n      <td>(590.0, 604.0]</td>\n      <td>50</td>\n      <td>98</td>\n      <td>47</td>\n      <td>98</td>\n      <td>0.510204</td>\n      <td>0.479592</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>2024.02.12~02.18</td>\n      <td>(604.0, inf]</td>\n      <td>20</td>\n      <td>65</td>\n      <td>16</td>\n      <td>65</td>\n      <td>0.307692</td>\n      <td>0.246154</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>2024.02.19~02.25</td>\n      <td>(-inf, 521.0]</td>\n      <td>1</td>\n      <td>2</td>\n      <td>0</td>\n      <td>2</td>\n      <td>0.500000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>2024.02.19~02.25</td>\n      <td>(521.0, 542.0]</td>\n      <td>8</td>\n      <td>16</td>\n      <td>8</td>\n      <td>16</td>\n      <td>0.500000</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>2024.02.19~02.25</td>\n      <td>(542.0, 573.0]</td>\n      <td>75</td>\n      <td>137</td>\n      <td>71</td>\n      <td>137</td>\n      <td>0.547445</td>\n      <td>0.518248</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>2024.02.19~02.25</td>\n      <td>(573.0, 590.0]</td>\n      <td>80</td>\n      <td>161</td>\n      <td>72</td>\n      <td>161</td>\n      <td>0.496894</td>\n      <td>0.447205</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>2024.02.19~02.25</td>\n      <td>(590.0, 604.0]</td>\n      <td>30</td>\n      <td>76</td>\n      <td>28</td>\n      <td>76</td>\n      <td>0.394737</td>\n      <td>0.368421</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>2024.02.19~02.25</td>\n      <td>(604.0, inf]</td>\n      <td>25</td>\n      <td>66</td>\n      <td>24</td>\n      <td>66</td>\n      <td>0.378788</td>\n      <td>0.363636</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>2024.02.26~03.03</td>\n      <td>(-inf, 521.0]</td>\n      <td>146</td>\n      <td>292</td>\n      <td>141</td>\n      <td>292</td>\n      <td>0.500000</td>\n      <td>0.482877</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>2024.02.26~03.03</td>\n      <td>(521.0, 542.0]</td>\n      <td>180</td>\n      <td>405</td>\n      <td>166</td>\n      <td>405</td>\n      <td>0.444444</td>\n      <td>0.409877</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>2024.02.26~03.03</td>\n      <td>(542.0, 573.0]</td>\n      <td>99</td>\n      <td>206</td>\n      <td>93</td>\n      <td>206</td>\n      <td>0.480583</td>\n      <td>0.451456</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>2024.02.26~03.03</td>\n      <td>(573.0, 590.0]</td>\n      <td>60</td>\n      <td>140</td>\n      <td>55</td>\n      <td>140</td>\n      <td>0.428571</td>\n      <td>0.392857</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>2024.02.26~03.03</td>\n      <td>(590.0, 604.0]</td>\n      <td>36</td>\n      <td>82</td>\n      <td>31</td>\n      <td>82</td>\n      <td>0.439024</td>\n      <td>0.378049</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>2024.02.26~03.03</td>\n      <td>(604.0, inf]</td>\n      <td>15</td>\n      <td>36</td>\n      <td>12</td>\n      <td>36</td>\n      <td>0.416667</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>2024.03.04~03.10</td>\n      <td>(-inf, 521.0]</td>\n      <td>19</td>\n      <td>46</td>\n      <td>18</td>\n      <td>46</td>\n      <td>0.413043</td>\n      <td>0.391304</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>2024.03.04~03.10</td>\n      <td>(521.0, 542.0]</td>\n      <td>40</td>\n      <td>81</td>\n      <td>38</td>\n      <td>81</td>\n      <td>0.493827</td>\n      <td>0.469136</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>2024.03.04~03.10</td>\n      <td>(542.0, 573.0]</td>\n      <td>77</td>\n      <td>155</td>\n      <td>74</td>\n      <td>155</td>\n      <td>0.496774</td>\n      <td>0.477419</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>2024.03.04~03.10</td>\n      <td>(573.0, 590.0]</td>\n      <td>41</td>\n      <td>92</td>\n      <td>37</td>\n      <td>92</td>\n      <td>0.445652</td>\n      <td>0.402174</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>2024.03.04~03.10</td>\n      <td>(590.0, 604.0]</td>\n      <td>13</td>\n      <td>41</td>\n      <td>12</td>\n      <td>41</td>\n      <td>0.317073</td>\n      <td>0.292683</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>2024.03.04~03.10</td>\n      <td>(604.0, inf]</td>\n      <td>15</td>\n      <td>35</td>\n      <td>15</td>\n      <td>35</td>\n      <td>0.428571</td>\n      <td>0.428571</td>\n    </tr>\n    <tr>\n      <th>48</th>\n      <td>2024.03.11~03.17</td>\n      <td>(-inf, 521.0]</td>\n      <td>28</td>\n      <td>49</td>\n      <td>24</td>\n      <td>49</td>\n      <td>0.571429</td>\n      <td>0.489796</td>\n    </tr>\n    <tr>\n      <th>49</th>\n      <td>2024.03.11~03.17</td>\n      <td>(521.0, 542.0]</td>\n      <td>69</td>\n      <td>164</td>\n      <td>66</td>\n      <td>164</td>\n      <td>0.420732</td>\n      <td>0.402439</td>\n    </tr>\n    <tr>\n      <th>50</th>\n      <td>2024.03.11~03.17</td>\n      <td>(542.0, 573.0]</td>\n      <td>96</td>\n      <td>198</td>\n      <td>89</td>\n      <td>198</td>\n      <td>0.484848</td>\n      <td>0.449495</td>\n    </tr>\n    <tr>\n      <th>51</th>\n      <td>2024.03.11~03.17</td>\n      <td>(573.0, 590.0]</td>\n      <td>42</td>\n      <td>93</td>\n      <td>37</td>\n      <td>93</td>\n      <td>0.451613</td>\n      <td>0.397849</td>\n    </tr>\n    <tr>\n      <th>52</th>\n      <td>2024.03.11~03.17</td>\n      <td>(590.0, 604.0]</td>\n      <td>17</td>\n      <td>50</td>\n      <td>15</td>\n      <td>50</td>\n      <td>0.340000</td>\n      <td>0.300000</td>\n    </tr>\n    <tr>\n      <th>53</th>\n      <td>2024.03.11~03.17</td>\n      <td>(604.0, inf]</td>\n      <td>11</td>\n      <td>32</td>\n      <td>11</td>\n      <td>32</td>\n      <td>0.343750</td>\n      <td>0.343750</td>\n    </tr>\n    <tr>\n      <th>54</th>\n      <td>2024.03.18~03.24</td>\n      <td>(-inf, 521.0]</td>\n      <td>17</td>\n      <td>33</td>\n      <td>17</td>\n      <td>33</td>\n      <td>0.515152</td>\n      <td>0.515152</td>\n    </tr>\n    <tr>\n      <th>55</th>\n      <td>2024.03.18~03.24</td>\n      <td>(521.0, 542.0]</td>\n      <td>71</td>\n      <td>160</td>\n      <td>70</td>\n      <td>160</td>\n      <td>0.443750</td>\n      <td>0.437500</td>\n    </tr>\n    <tr>\n      <th>56</th>\n      <td>2024.03.18~03.24</td>\n      <td>(542.0, 573.0]</td>\n      <td>73</td>\n      <td>174</td>\n      <td>67</td>\n      <td>174</td>\n      <td>0.419540</td>\n      <td>0.385057</td>\n    </tr>\n    <tr>\n      <th>57</th>\n      <td>2024.03.18~03.24</td>\n      <td>(573.0, 590.0]</td>\n      <td>28</td>\n      <td>78</td>\n      <td>26</td>\n      <td>78</td>\n      <td>0.358974</td>\n      <td>0.333333</td>\n    </tr>\n    <tr>\n      <th>58</th>\n      <td>2024.03.18~03.24</td>\n      <td>(590.0, 604.0]</td>\n      <td>11</td>\n      <td>36</td>\n      <td>10</td>\n      <td>36</td>\n      <td>0.305556</td>\n      <td>0.277778</td>\n    </tr>\n    <tr>\n      <th>59</th>\n      <td>2024.03.18~03.24</td>\n      <td>(604.0, inf]</td>\n      <td>11</td>\n      <td>25</td>\n      <td>10</td>\n      <td>25</td>\n      <td>0.440000</td>\n      <td>0.400000</td>\n    </tr>\n    <tr>\n      <th>60</th>\n      <td>2024.03.25~03.31</td>\n      <td>(-inf, 521.0]</td>\n      <td>10</td>\n      <td>16</td>\n      <td>10</td>\n      <td>16</td>\n      <td>0.625000</td>\n      <td>0.625000</td>\n    </tr>\n    <tr>\n      <th>61</th>\n      <td>2024.03.25~03.31</td>\n      <td>(521.0, 542.0]</td>\n      <td>30</td>\n      <td>76</td>\n      <td>27</td>\n      <td>76</td>\n      <td>0.394737</td>\n      <td>0.355263</td>\n    </tr>\n    <tr>\n      <th>62</th>\n      <td>2024.03.25~03.31</td>\n      <td>(542.0, 573.0]</td>\n      <td>43</td>\n      <td>105</td>\n      <td>40</td>\n      <td>105</td>\n      <td>0.409524</td>\n      <td>0.380952</td>\n    </tr>\n    <tr>\n      <th>63</th>\n      <td>2024.03.25~03.31</td>\n      <td>(573.0, 590.0]</td>\n      <td>24</td>\n      <td>60</td>\n      <td>23</td>\n      <td>60</td>\n      <td>0.400000</td>\n      <td>0.383333</td>\n    </tr>\n    <tr>\n      <th>64</th>\n      <td>2024.03.25~03.31</td>\n      <td>(590.0, 604.0]</td>\n      <td>14</td>\n      <td>33</td>\n      <td>13</td>\n      <td>33</td>\n      <td>0.424242</td>\n      <td>0.393939</td>\n    </tr>\n    <tr>\n      <th>65</th>\n      <td>2024.03.25~03.31</td>\n      <td>(604.0, inf]</td>\n      <td>8</td>\n      <td>18</td>\n      <td>7</td>\n      <td>18</td>\n      <td>0.444444</td>\n      <td>0.388889</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']==0)&(df['scorev9']>0)\n",
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "df['scorev9_bin'] = pd.cut(df['scorev9'],[-np.inf,521,542,573,590,604,np.inf])\n",
    "group=['repayment_week','scorev9_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:20:51.011426Z",
     "start_time": "2024-04-01T04:20:50.981124Z"
    }
   },
   "execution_count": 54
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev10"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            var   target             bin  negative  positive  total  \\\n0  scorev10_bin  def_pd1   (-inf, 530.0]       106        79    185   \n1  scorev10_bin  def_pd1  (530.0, 580.0]      1894      1094   2988   \n2  scorev10_bin  def_pd1  (580.0, 590.0]      1118       527   1645   \n3  scorev10_bin  def_pd1    (590.0, inf]       460       242    702   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.033514       0.427027 -0.308182  1.213795  0.045045  0.011416  \n1    0.541304       0.366131 -0.062122  1.040702  0.045045  0.011416  \n2    0.298007       0.320365  0.140528  0.910615  0.045045  0.011416  \n3    0.127174       0.344729  0.030959  0.979869  0.045045  0.011416  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev10_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 530.0]</td>\n      <td>106</td>\n      <td>79</td>\n      <td>185</td>\n      <td>0.033514</td>\n      <td>0.427027</td>\n      <td>-0.308182</td>\n      <td>1.213795</td>\n      <td>0.045045</td>\n      <td>0.011416</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev10_bin</td>\n      <td>def_pd1</td>\n      <td>(530.0, 580.0]</td>\n      <td>1894</td>\n      <td>1094</td>\n      <td>2988</td>\n      <td>0.541304</td>\n      <td>0.366131</td>\n      <td>-0.062122</td>\n      <td>1.040702</td>\n      <td>0.045045</td>\n      <td>0.011416</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev10_bin</td>\n      <td>def_pd1</td>\n      <td>(580.0, 590.0]</td>\n      <td>1118</td>\n      <td>527</td>\n      <td>1645</td>\n      <td>0.298007</td>\n      <td>0.320365</td>\n      <td>0.140528</td>\n      <td>0.910615</td>\n      <td>0.045045</td>\n      <td>0.011416</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev10_bin</td>\n      <td>def_pd1</td>\n      <td>(590.0, inf]</td>\n      <td>460</td>\n      <td>242</td>\n      <td>702</td>\n      <td>0.127174</td>\n      <td>0.344729</td>\n      <td>0.030959</td>\n      <td>0.979869</td>\n      <td>0.045045</td>\n      <td>0.011416</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition= (df['merchant_id'] == 'AM')&(df['device_type']=='android')&(df['new_old_user_status']>0)&(df['scorev10']>0) & (df['apply_time']>=pd.to_datetime(\"2024-02-07\"))\n",
    "df['scorev10_bin'] = pd.cut(df['scorev10'],[-np.inf,530,580,590,np.inf ])\n",
    "univerate(df[condition],'scorev10_bin','def_pd1') "
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T04:23:01.025947Z",
     "start_time": "2024-04-01T04:23:00.990230Z"
    }
   },
   "execution_count": 56
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scoreV11"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            var   target             bin  negative  positive  total  \\\n0  scorev11_bin  def_pd1    (0.0, 619.0]      1759      1107   2866   \n1  scorev11_bin  def_pd1  (619.0, 629.0]      1103       497   1600   \n2  scorev11_bin  def_pd1  (629.0, 640.0]       951       290   1241   \n3  scorev11_bin  def_pd1    (640.0, inf]       341        58    399   \n\n   total_rate  positive_rate       woe      LIFT        KS       IV  \n0    0.469374       0.386253 -0.291528  1.208227  0.143663  0.12903  \n1    0.262037       0.310625  0.041821  0.971658  0.143663  0.12903  \n2    0.203243       0.233683  0.430066  0.730976  0.143663  0.12903  \n3    0.065346       0.145363  0.995229  0.454707  0.143663  0.12903  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev11_bin</td>\n      <td>def_pd1</td>\n      <td>(0.0, 619.0]</td>\n      <td>1759</td>\n      <td>1107</td>\n      <td>2866</td>\n      <td>0.469374</td>\n      <td>0.386253</td>\n      <td>-0.291528</td>\n      <td>1.208227</td>\n      <td>0.143663</td>\n      <td>0.12903</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev11_bin</td>\n      <td>def_pd1</td>\n      <td>(619.0, 629.0]</td>\n      <td>1103</td>\n      <td>497</td>\n      <td>1600</td>\n      <td>0.262037</td>\n      <td>0.310625</td>\n      <td>0.041821</td>\n      <td>0.971658</td>\n      <td>0.143663</td>\n      <td>0.12903</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev11_bin</td>\n      <td>def_pd1</td>\n      <td>(629.0, 640.0]</td>\n      <td>951</td>\n      <td>290</td>\n      <td>1241</td>\n      <td>0.203243</td>\n      <td>0.233683</td>\n      <td>0.430066</td>\n      <td>0.730976</td>\n      <td>0.143663</td>\n      <td>0.12903</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev11_bin</td>\n      <td>def_pd1</td>\n      <td>(640.0, inf]</td>\n      <td>341</td>\n      <td>58</td>\n      <td>399</td>\n      <td>0.065346</td>\n      <td>0.145363</td>\n      <td>0.995229</td>\n      <td>0.454707</td>\n      <td>0.143663</td>\n      <td>0.12903</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>=1) & (df['scorev11']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-04\"))\n",
    "df['scorev11_bin'] = pd.cut(df['scorev11'],[0,619,629,640,np.inf])\n",
    "univerate(df[condition],'scorev11_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:12:43.665138Z",
     "start_time": "2024-04-01T06:12:43.627018Z"
    }
   },
   "execution_count": 95
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week    scorev11_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.03.04~03.10    (0.0, 619.0]       25       52       21       52   \n1   2024.03.04~03.10  (619.0, 629.0]        7       29        4       29   \n2   2024.03.04~03.10  (629.0, 640.0]        0        8        0        8   \n3   2024.03.04~03.10    (640.0, inf]        5       12        5       12   \n4   2024.03.11~03.17    (0.0, 619.0]      512     1342      404     1342   \n5   2024.03.11~03.17  (619.0, 629.0]      187      601      164      601   \n6   2024.03.11~03.17  (629.0, 640.0]      123      580       96      580   \n7   2024.03.11~03.17    (640.0, inf]       20      184       11      184   \n8   2024.03.18~03.24    (0.0, 619.0]      334      877      297      877   \n9   2024.03.18~03.24  (619.0, 629.0]      161      521      138      521   \n10  2024.03.18~03.24  (629.0, 640.0]       90      368       68      368   \n11  2024.03.18~03.24    (640.0, inf]       24      130       22      130   \n12  2024.03.25~03.31    (0.0, 619.0]      236      595      213      595   \n13  2024.03.25~03.31  (619.0, 629.0]      142      449      134      449   \n14  2024.03.25~03.31  (629.0, 640.0]       77      285       68      285   \n15  2024.03.25~03.31    (640.0, inf]        9       73        5       73   \n\n         pd1       cpd  \n0   0.480769  0.403846  \n1   0.241379  0.137931  \n2   0.000000  0.000000  \n3   0.416667  0.416667  \n4   0.381520  0.301043  \n5   0.311148  0.272879  \n6   0.212069  0.165517  \n7   0.108696  0.059783  \n8   0.380844  0.338655  \n9   0.309021  0.264875  \n10  0.244565  0.184783  \n11  0.184615  0.169231  \n12  0.396639  0.357983  \n13  0.316258  0.298441  \n14  0.270175  0.238596  \n15  0.123288  0.068493  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev11_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.03.04~03.10</td>\n      <td>(0.0, 619.0]</td>\n      <td>25</td>\n      <td>52</td>\n      <td>21</td>\n      <td>52</td>\n      <td>0.480769</td>\n      <td>0.403846</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.03.04~03.10</td>\n      <td>(619.0, 629.0]</td>\n      <td>7</td>\n      <td>29</td>\n      <td>4</td>\n      <td>29</td>\n      <td>0.241379</td>\n      <td>0.137931</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.03.04~03.10</td>\n      <td>(629.0, 640.0]</td>\n      <td>0</td>\n      <td>8</td>\n      <td>0</td>\n      <td>8</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.03.04~03.10</td>\n      <td>(640.0, inf]</td>\n      <td>5</td>\n      <td>12</td>\n      <td>5</td>\n      <td>12</td>\n      <td>0.416667</td>\n      <td>0.416667</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.03.11~03.17</td>\n      <td>(0.0, 619.0]</td>\n      <td>512</td>\n      <td>1342</td>\n      <td>404</td>\n      <td>1342</td>\n      <td>0.381520</td>\n      <td>0.301043</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.03.11~03.17</td>\n      <td>(619.0, 629.0]</td>\n      <td>187</td>\n      <td>601</td>\n      <td>164</td>\n      <td>601</td>\n      <td>0.311148</td>\n      <td>0.272879</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.03.11~03.17</td>\n      <td>(629.0, 640.0]</td>\n      <td>123</td>\n      <td>580</td>\n      <td>96</td>\n      <td>580</td>\n      <td>0.212069</td>\n      <td>0.165517</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.03.11~03.17</td>\n      <td>(640.0, inf]</td>\n      <td>20</td>\n      <td>184</td>\n      <td>11</td>\n      <td>184</td>\n      <td>0.108696</td>\n      <td>0.059783</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.03.18~03.24</td>\n      <td>(0.0, 619.0]</td>\n      <td>334</td>\n      <td>877</td>\n      <td>297</td>\n      <td>877</td>\n      <td>0.380844</td>\n      <td>0.338655</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.03.18~03.24</td>\n      <td>(619.0, 629.0]</td>\n      <td>161</td>\n      <td>521</td>\n      <td>138</td>\n      <td>521</td>\n      <td>0.309021</td>\n      <td>0.264875</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.03.18~03.24</td>\n      <td>(629.0, 640.0]</td>\n      <td>90</td>\n      <td>368</td>\n      <td>68</td>\n      <td>368</td>\n      <td>0.244565</td>\n      <td>0.184783</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.03.18~03.24</td>\n      <td>(640.0, inf]</td>\n      <td>24</td>\n      <td>130</td>\n      <td>22</td>\n      <td>130</td>\n      <td>0.184615</td>\n      <td>0.169231</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>2024.03.25~03.31</td>\n      <td>(0.0, 619.0]</td>\n      <td>236</td>\n      <td>595</td>\n      <td>213</td>\n      <td>595</td>\n      <td>0.396639</td>\n      <td>0.357983</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>2024.03.25~03.31</td>\n      <td>(619.0, 629.0]</td>\n      <td>142</td>\n      <td>449</td>\n      <td>134</td>\n      <td>449</td>\n      <td>0.316258</td>\n      <td>0.298441</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>2024.03.25~03.31</td>\n      <td>(629.0, 640.0]</td>\n      <td>77</td>\n      <td>285</td>\n      <td>68</td>\n      <td>285</td>\n      <td>0.270175</td>\n      <td>0.238596</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>2024.03.25~03.31</td>\n      <td>(640.0, inf]</td>\n      <td>9</td>\n      <td>73</td>\n      <td>5</td>\n      <td>73</td>\n      <td>0.123288</td>\n      <td>0.068493</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_col=['def_pd1', 'agr_pd1','def_cpd','agr_cpd']\n",
    "rate_tupes=[('def_pd1','agr_pd1','pd1'),('def_cpd','agr_cpd','cpd')]\n",
    "group=['repayment_week','scorev11_bin']\n",
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:12:45.830299Z",
     "start_time": "2024-04-01T06:12:45.816299Z"
    }
   },
   "execution_count": 96
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scoreV12"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            var   target             bin  negative  positive  total  \\\n0  scorev12_bin  def_pd1   (-inf, 520.0]        74        96    170   \n1  scorev12_bin  def_pd1  (520.0, 558.0]       170       207    377   \n2  scorev12_bin  def_pd1  (558.0, 620.0]       230       189    419   \n3  scorev12_bin  def_pd1  (620.0, 650.0]        53        27     80   \n4  scorev12_bin  def_pd1    (650.0, inf]        77        20     97   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.148731       0.564706 -0.371612  1.197512  0.158179  0.185563  \n1    0.329834       0.549072 -0.309833  1.164358  0.158179  0.185563  \n2    0.366579       0.451074  0.082249  0.956545  0.158179  0.185563  \n3    0.069991       0.337500  0.552162  0.715700  0.158179  0.185563  \n4    0.084864       0.206186  1.215435  0.437236  0.158179  0.185563  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 520.0]</td>\n      <td>74</td>\n      <td>96</td>\n      <td>170</td>\n      <td>0.148731</td>\n      <td>0.564706</td>\n      <td>-0.371612</td>\n      <td>1.197512</td>\n      <td>0.158179</td>\n      <td>0.185563</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 558.0]</td>\n      <td>170</td>\n      <td>207</td>\n      <td>377</td>\n      <td>0.329834</td>\n      <td>0.549072</td>\n      <td>-0.309833</td>\n      <td>1.164358</td>\n      <td>0.158179</td>\n      <td>0.185563</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(558.0, 620.0]</td>\n      <td>230</td>\n      <td>189</td>\n      <td>419</td>\n      <td>0.366579</td>\n      <td>0.451074</td>\n      <td>0.082249</td>\n      <td>0.956545</td>\n      <td>0.158179</td>\n      <td>0.185563</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(620.0, 650.0]</td>\n      <td>53</td>\n      <td>27</td>\n      <td>80</td>\n      <td>0.069991</td>\n      <td>0.337500</td>\n      <td>0.552162</td>\n      <td>0.715700</td>\n      <td>0.158179</td>\n      <td>0.185563</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(650.0, inf]</td>\n      <td>77</td>\n      <td>20</td>\n      <td>97</td>\n      <td>0.084864</td>\n      <td>0.206186</td>\n      <td>1.215435</td>\n      <td>0.437236</td>\n      <td>0.158179</td>\n      <td>0.185563</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']==0) & (df['scorev12']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-04\"))\n",
    "df['scorev12_bin'] = pd.cut(df['scorev12'],[-np.inf,520,558,620,650,np.inf])\n",
    "univerate(df[condition],'scorev12_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:16:19.284672Z",
     "start_time": "2024-04-01T06:16:19.249451Z"
    }
   },
   "execution_count": 100
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week    scorev11_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.03.11~03.17    (0.0, 619.0]      158      299      147      299   \n1   2024.03.11~03.17  (619.0, 629.0]       57      108       54      108   \n2   2024.03.11~03.17  (629.0, 640.0]       10       53        6       53   \n3   2024.03.11~03.17    (640.0, inf]        5       22        4       22   \n4   2024.03.18~03.24    (0.0, 619.0]      155      305      141      305   \n5   2024.03.18~03.24  (619.0, 629.0]       53      123       47      123   \n6   2024.03.18~03.24  (629.0, 640.0]       18       41       15       41   \n7   2024.03.18~03.24    (640.0, inf]        9       24        6       24   \n8   2024.03.25~03.31    (0.0, 619.0]       44       96       41       96   \n9   2024.03.25~03.31  (619.0, 629.0]       21       44       17       44   \n10  2024.03.25~03.31  (629.0, 640.0]        6       20        5       20   \n11  2024.03.25~03.31    (640.0, inf]        3        8        3        8   \n\n         pd1       cpd  \n0   0.528428  0.491639  \n1   0.527778  0.500000  \n2   0.188679  0.113208  \n3   0.227273  0.181818  \n4   0.508197  0.462295  \n5   0.430894  0.382114  \n6   0.439024  0.365854  \n7   0.375000  0.250000  \n8   0.458333  0.427083  \n9   0.477273  0.386364  \n10  0.300000  0.250000  \n11  0.375000  0.375000  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev11_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.03.11~03.17</td>\n      <td>(0.0, 619.0]</td>\n      <td>158</td>\n      <td>299</td>\n      <td>147</td>\n      <td>299</td>\n      <td>0.528428</td>\n      <td>0.491639</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.03.11~03.17</td>\n      <td>(619.0, 629.0]</td>\n      <td>57</td>\n      <td>108</td>\n      <td>54</td>\n      <td>108</td>\n      <td>0.527778</td>\n      <td>0.500000</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.03.11~03.17</td>\n      <td>(629.0, 640.0]</td>\n      <td>10</td>\n      <td>53</td>\n      <td>6</td>\n      <td>53</td>\n      <td>0.188679</td>\n      <td>0.113208</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.03.11~03.17</td>\n      <td>(640.0, inf]</td>\n      <td>5</td>\n      <td>22</td>\n      <td>4</td>\n      <td>22</td>\n      <td>0.227273</td>\n      <td>0.181818</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.03.18~03.24</td>\n      <td>(0.0, 619.0]</td>\n      <td>155</td>\n      <td>305</td>\n      <td>141</td>\n      <td>305</td>\n      <td>0.508197</td>\n      <td>0.462295</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.03.18~03.24</td>\n      <td>(619.0, 629.0]</td>\n      <td>53</td>\n      <td>123</td>\n      <td>47</td>\n      <td>123</td>\n      <td>0.430894</td>\n      <td>0.382114</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.03.18~03.24</td>\n      <td>(629.0, 640.0]</td>\n      <td>18</td>\n      <td>41</td>\n      <td>15</td>\n      <td>41</td>\n      <td>0.439024</td>\n      <td>0.365854</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.03.18~03.24</td>\n      <td>(640.0, inf]</td>\n      <td>9</td>\n      <td>24</td>\n      <td>6</td>\n      <td>24</td>\n      <td>0.375000</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.03.25~03.31</td>\n      <td>(0.0, 619.0]</td>\n      <td>44</td>\n      <td>96</td>\n      <td>41</td>\n      <td>96</td>\n      <td>0.458333</td>\n      <td>0.427083</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.03.25~03.31</td>\n      <td>(619.0, 629.0]</td>\n      <td>21</td>\n      <td>44</td>\n      <td>17</td>\n      <td>44</td>\n      <td>0.477273</td>\n      <td>0.386364</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.03.25~03.31</td>\n      <td>(629.0, 640.0]</td>\n      <td>6</td>\n      <td>20</td>\n      <td>5</td>\n      <td>20</td>\n      <td>0.300000</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.03.25~03.31</td>\n      <td>(640.0, inf]</td>\n      <td>3</td>\n      <td>8</td>\n      <td>3</td>\n      <td>8</td>\n      <td>0.375000</td>\n      <td>0.375000</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:16:21.852928Z",
     "start_time": "2024-04-01T06:16:21.841197Z"
    }
   },
   "execution_count": 101
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            var   target             bin  negative  positive  total  \\\n0  scorev12_bin  def_pd1   (-inf, 520.0]        59        48    107   \n1  scorev12_bin  def_pd1  (520.0, 558.0]       377       304    681   \n2  scorev12_bin  def_pd1  (558.0, 620.0]      1668       893   2561   \n3  scorev12_bin  def_pd1  (620.0, 650.0]       670       204    874   \n4  scorev12_bin  def_pd1    (650.0, inf]       647       174    821   \n\n   total_rate  positive_rate       woe      LIFT        KS       IV  \n0    0.021213       0.448598 -0.516209  1.394164  0.152073  0.13162  \n1    0.135012       0.446402 -0.526730  1.387340  0.152073  0.13162  \n2    0.507732       0.348692 -0.120630  1.083673  0.152073  0.13162  \n3    0.173275       0.233410  0.440670  0.725396  0.152073  0.13162  \n4    0.162768       0.211937  0.563624  0.658662  0.152073  0.13162  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 520.0]</td>\n      <td>59</td>\n      <td>48</td>\n      <td>107</td>\n      <td>0.021213</td>\n      <td>0.448598</td>\n      <td>-0.516209</td>\n      <td>1.394164</td>\n      <td>0.152073</td>\n      <td>0.13162</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 558.0]</td>\n      <td>377</td>\n      <td>304</td>\n      <td>681</td>\n      <td>0.135012</td>\n      <td>0.446402</td>\n      <td>-0.526730</td>\n      <td>1.387340</td>\n      <td>0.152073</td>\n      <td>0.13162</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(558.0, 620.0]</td>\n      <td>1668</td>\n      <td>893</td>\n      <td>2561</td>\n      <td>0.507732</td>\n      <td>0.348692</td>\n      <td>-0.120630</td>\n      <td>1.083673</td>\n      <td>0.152073</td>\n      <td>0.13162</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(620.0, 650.0]</td>\n      <td>670</td>\n      <td>204</td>\n      <td>874</td>\n      <td>0.173275</td>\n      <td>0.233410</td>\n      <td>0.440670</td>\n      <td>0.725396</td>\n      <td>0.152073</td>\n      <td>0.13162</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev12_bin</td>\n      <td>def_pd1</td>\n      <td>(650.0, inf]</td>\n      <td>647</td>\n      <td>174</td>\n      <td>821</td>\n      <td>0.162768</td>\n      <td>0.211937</td>\n      <td>0.563624</td>\n      <td>0.658662</td>\n      <td>0.152073</td>\n      <td>0.13162</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AC') & (df['device_type']=='android') & (df['new_old_user_status']>0) & (df['scorev12']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-04\"))\n",
    "df['scorev12_bin'] = pd.cut(df['scorev12'],[-np.inf,520,558,620,650,np.inf])\n",
    "univerate(df[condition],'scorev12_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:20:12.040355Z",
     "start_time": "2024-04-01T06:20:12.006717Z"
    }
   },
   "execution_count": 103
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "      repayment_week    scorev11_bin  def_pd1  agr_pd1  def_cpd  agr_cpd  \\\n0   2024.03.11~03.17    (0.0, 619.0]      386      934      306      934   \n1   2024.03.11~03.17  (619.0, 629.0]      114      408      102      408   \n2   2024.03.11~03.17  (629.0, 640.0]       62      341       49      341   \n3   2024.03.11~03.17    (640.0, inf]       11      131        6      131   \n4   2024.03.18~03.24    (0.0, 619.0]      320      846      286      846   \n5   2024.03.18~03.24  (619.0, 629.0]      160      511      137      511   \n6   2024.03.18~03.24  (629.0, 640.0]       84      355       63      355   \n7   2024.03.18~03.24    (640.0, inf]       24      127       22      127   \n8   2024.03.25~03.31    (0.0, 619.0]      235      590      212      590   \n9   2024.03.25~03.31  (619.0, 629.0]      141      445      133      445   \n10  2024.03.25~03.31  (629.0, 640.0]       77      283       68      283   \n11  2024.03.25~03.31    (640.0, inf]        9       73        5       73   \n\n         pd1       cpd  \n0   0.413276  0.327623  \n1   0.279412  0.250000  \n2   0.181818  0.143695  \n3   0.083969  0.045802  \n4   0.378251  0.338061  \n5   0.313112  0.268102  \n6   0.236620  0.177465  \n7   0.188976  0.173228  \n8   0.398305  0.359322  \n9   0.316854  0.298876  \n10  0.272085  0.240283  \n11  0.123288  0.068493  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>repayment_week</th>\n      <th>scorev11_bin</th>\n      <th>def_pd1</th>\n      <th>agr_pd1</th>\n      <th>def_cpd</th>\n      <th>agr_cpd</th>\n      <th>pd1</th>\n      <th>cpd</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2024.03.11~03.17</td>\n      <td>(0.0, 619.0]</td>\n      <td>386</td>\n      <td>934</td>\n      <td>306</td>\n      <td>934</td>\n      <td>0.413276</td>\n      <td>0.327623</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2024.03.11~03.17</td>\n      <td>(619.0, 629.0]</td>\n      <td>114</td>\n      <td>408</td>\n      <td>102</td>\n      <td>408</td>\n      <td>0.279412</td>\n      <td>0.250000</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>2024.03.11~03.17</td>\n      <td>(629.0, 640.0]</td>\n      <td>62</td>\n      <td>341</td>\n      <td>49</td>\n      <td>341</td>\n      <td>0.181818</td>\n      <td>0.143695</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2024.03.11~03.17</td>\n      <td>(640.0, inf]</td>\n      <td>11</td>\n      <td>131</td>\n      <td>6</td>\n      <td>131</td>\n      <td>0.083969</td>\n      <td>0.045802</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2024.03.18~03.24</td>\n      <td>(0.0, 619.0]</td>\n      <td>320</td>\n      <td>846</td>\n      <td>286</td>\n      <td>846</td>\n      <td>0.378251</td>\n      <td>0.338061</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2024.03.18~03.24</td>\n      <td>(619.0, 629.0]</td>\n      <td>160</td>\n      <td>511</td>\n      <td>137</td>\n      <td>511</td>\n      <td>0.313112</td>\n      <td>0.268102</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>2024.03.18~03.24</td>\n      <td>(629.0, 640.0]</td>\n      <td>84</td>\n      <td>355</td>\n      <td>63</td>\n      <td>355</td>\n      <td>0.236620</td>\n      <td>0.177465</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>2024.03.18~03.24</td>\n      <td>(640.0, inf]</td>\n      <td>24</td>\n      <td>127</td>\n      <td>22</td>\n      <td>127</td>\n      <td>0.188976</td>\n      <td>0.173228</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>2024.03.25~03.31</td>\n      <td>(0.0, 619.0]</td>\n      <td>235</td>\n      <td>590</td>\n      <td>212</td>\n      <td>590</td>\n      <td>0.398305</td>\n      <td>0.359322</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>2024.03.25~03.31</td>\n      <td>(619.0, 629.0]</td>\n      <td>141</td>\n      <td>445</td>\n      <td>133</td>\n      <td>445</td>\n      <td>0.316854</td>\n      <td>0.298876</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>2024.03.25~03.31</td>\n      <td>(629.0, 640.0]</td>\n      <td>77</td>\n      <td>283</td>\n      <td>68</td>\n      <td>283</td>\n      <td>0.272085</td>\n      <td>0.240283</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>2024.03.25~03.31</td>\n      <td>(640.0, inf]</td>\n      <td>9</td>\n      <td>73</td>\n      <td>5</td>\n      <td>73</td>\n      <td>0.123288</td>\n      <td>0.068493</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "group_calc(df[condition],group,sum_col,None,None,rate_tupes).reset_index()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:20:14.200518Z",
     "start_time": "2024-04-01T06:20:14.187901Z"
    }
   },
   "execution_count": 104
  },
  {
   "cell_type": "markdown",
   "source": [
    "# scorev13"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            var   target             bin  negative  positive  total  \\\n0  scorev13_bin  def_pd1   (-inf, 520.0]        46       131    177   \n1  scorev13_bin  def_pd1  (520.0, 550.0]       133       177    310   \n2  scorev13_bin  def_pd1  (550.0, 570.0]       217       259    476   \n3  scorev13_bin  def_pd1  (570.0, 590.0]       271       232    503   \n4  scorev13_bin  def_pd1  (590.0, 610.0]       176       101    277   \n5  scorev13_bin  def_pd1  (610.0, 630.0]       125        47    172   \n6  scorev13_bin  def_pd1    (630.0, inf]        67        17     84   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.088544       0.740113 -1.102703  1.534736  0.205566  0.291936  \n1    0.155078       0.570968 -0.354546  1.183988  0.205566  0.291936  \n2    0.238119       0.544118 -0.246953  1.128310  0.205566  0.291936  \n3    0.251626       0.461233  0.083981  0.956436  0.205566  0.291936  \n4    0.138569       0.364621  0.480662  0.756097  0.205566  0.291936  \n5    0.086043       0.273256  0.895044  0.566637  0.205566  0.291936  \n6    0.042021       0.202381  1.260587  0.419668  0.205566  0.291936  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 520.0]</td>\n      <td>46</td>\n      <td>131</td>\n      <td>177</td>\n      <td>0.088544</td>\n      <td>0.740113</td>\n      <td>-1.102703</td>\n      <td>1.534736</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 550.0]</td>\n      <td>133</td>\n      <td>177</td>\n      <td>310</td>\n      <td>0.155078</td>\n      <td>0.570968</td>\n      <td>-0.354546</td>\n      <td>1.183988</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(550.0, 570.0]</td>\n      <td>217</td>\n      <td>259</td>\n      <td>476</td>\n      <td>0.238119</td>\n      <td>0.544118</td>\n      <td>-0.246953</td>\n      <td>1.128310</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(570.0, 590.0]</td>\n      <td>271</td>\n      <td>232</td>\n      <td>503</td>\n      <td>0.251626</td>\n      <td>0.461233</td>\n      <td>0.083981</td>\n      <td>0.956436</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(590.0, 610.0]</td>\n      <td>176</td>\n      <td>101</td>\n      <td>277</td>\n      <td>0.138569</td>\n      <td>0.364621</td>\n      <td>0.480662</td>\n      <td>0.756097</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(610.0, 630.0]</td>\n      <td>125</td>\n      <td>47</td>\n      <td>172</td>\n      <td>0.086043</td>\n      <td>0.273256</td>\n      <td>0.895044</td>\n      <td>0.566637</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(630.0, inf]</td>\n      <td>67</td>\n      <td>17</td>\n      <td>84</td>\n      <td>0.042021</td>\n      <td>0.202381</td>\n      <td>1.260587</td>\n      <td>0.419668</td>\n      <td>0.205566</td>\n      <td>0.291936</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AG') & (df['device_type']=='android') & (df['new_old_user_status']==0) & (df['scorev13']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-13\"))\n",
    "df['scorev13_bin'] = pd.cut(df['scorev13'],[-np.inf,520,550,570,590,610,630,np.inf])\n",
    "univerate(df[condition],'scorev13_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:30:29.866962Z",
     "start_time": "2024-04-01T06:30:29.835134Z"
    }
   },
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "            var   target             bin  negative  positive  total  \\\n0  scorev13_bin  def_pd1   (-inf, 520.0]        13        13     26   \n1  scorev13_bin  def_pd1  (520.0, 550.0]        68        63    131   \n2  scorev13_bin  def_pd1  (550.0, 570.0]       143        81    224   \n3  scorev13_bin  def_pd1  (570.0, 590.0]       192        75    267   \n4  scorev13_bin  def_pd1  (590.0, 610.0]       194        57    251   \n5  scorev13_bin  def_pd1  (610.0, 630.0]        91        34    125   \n6  scorev13_bin  def_pd1    (630.0, inf]        46        10     56   \n\n   total_rate  positive_rate       woe      LIFT        KS        IV  \n0    0.024074       0.500000 -0.777344  1.621622  0.171605  0.166923  \n1    0.121296       0.480916 -0.725896  1.559728  0.171605  0.166923  \n2    0.207407       0.361607 -0.238420  1.172780  0.171605  0.166923  \n3    0.247222       0.280899  0.131537  0.911023  0.171605  0.166923  \n4    0.232407       0.227092  0.414902  0.736513  0.171605  0.166923  \n5    0.115741       0.272000  0.175005  0.882162  0.171605  0.166923  \n6    0.051852       0.178571  0.701485  0.579151  0.171605  0.166923  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>var</th>\n      <th>target</th>\n      <th>bin</th>\n      <th>negative</th>\n      <th>positive</th>\n      <th>total</th>\n      <th>total_rate</th>\n      <th>positive_rate</th>\n      <th>woe</th>\n      <th>LIFT</th>\n      <th>KS</th>\n      <th>IV</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(-inf, 520.0]</td>\n      <td>13</td>\n      <td>13</td>\n      <td>26</td>\n      <td>0.024074</td>\n      <td>0.500000</td>\n      <td>-0.777344</td>\n      <td>1.621622</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(520.0, 550.0]</td>\n      <td>68</td>\n      <td>63</td>\n      <td>131</td>\n      <td>0.121296</td>\n      <td>0.480916</td>\n      <td>-0.725896</td>\n      <td>1.559728</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(550.0, 570.0]</td>\n      <td>143</td>\n      <td>81</td>\n      <td>224</td>\n      <td>0.207407</td>\n      <td>0.361607</td>\n      <td>-0.238420</td>\n      <td>1.172780</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(570.0, 590.0]</td>\n      <td>192</td>\n      <td>75</td>\n      <td>267</td>\n      <td>0.247222</td>\n      <td>0.280899</td>\n      <td>0.131537</td>\n      <td>0.911023</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(590.0, 610.0]</td>\n      <td>194</td>\n      <td>57</td>\n      <td>251</td>\n      <td>0.232407</td>\n      <td>0.227092</td>\n      <td>0.414902</td>\n      <td>0.736513</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(610.0, 630.0]</td>\n      <td>91</td>\n      <td>34</td>\n      <td>125</td>\n      <td>0.115741</td>\n      <td>0.272000</td>\n      <td>0.175005</td>\n      <td>0.882162</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>scorev13_bin</td>\n      <td>def_pd1</td>\n      <td>(630.0, inf]</td>\n      <td>46</td>\n      <td>10</td>\n      <td>56</td>\n      <td>0.051852</td>\n      <td>0.178571</td>\n      <td>0.701485</td>\n      <td>0.579151</td>\n      <td>0.171605</td>\n      <td>0.166923</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "condition =(df['merchant_id']=='AG') & (df['device_type']=='android') & (df['new_old_user_status']>0) & (df['scorev13']>=0) & (df['apply_time']>=pd.to_datetime(\"2024-03-13\"))\n",
    "df['scorev13_bin'] = pd.cut(df['scorev13'],[-np.inf,520,550,570,590,610,630,np.inf])\n",
    "univerate(df[condition],'scorev13_bin','def_pd1')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-04-01T06:38:27.680092Z",
     "start_time": "2024-04-01T06:38:27.644095Z"
    }
   },
   "execution_count": 21
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py311",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
